Skip to content

Commit c10a10a

Browse files
fix(FileSystemAccessApiFsClient): client may throw TypeError in Safari
1 parent 6025f17 commit c10a10a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/clients/fs/FileSystemAccessApiFsClient.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,18 @@ export class FileSystemAccessApiFsClient implements FsClient {
231231

232232
return targetDir
233233
} catch (error: any) {
234-
const { name } = error
235-
switch (name) {
236-
case ErrorNames.NotFoundError: throw new ENOENT(path)
237-
case ErrorNames.TypeMismatchError: throw new ENOTDIR(path)
238-
default: throw error
234+
if (error instanceof TypeError) {
235+
throw new ENOTDIR(path)
239236
}
237+
238+
if (error instanceof DOMException) {
239+
switch (error.name) {
240+
case ErrorNames.NotFoundError: throw new ENOENT(path)
241+
case ErrorNames.TypeMismatchError: throw new ENOTDIR(path)
242+
}
243+
}
244+
245+
throw error
240246
}
241247
}
242248

0 commit comments

Comments
 (0)