MCPcopy Create free account
hub / github.com/Effect-TS/effect / handleError

Function handleError

packages/platform/deno/src/internal/error.ts:9–66  ·  view source on GitHub ↗
(
  module: SystemError["module"],
  method: string,
  pathOrDescriptor?: string | number
)

Source from the content-addressed store, hash-verified

7}
8
9export const handleError = (
10 module: SystemError["module"],
11 method: string,
12 pathOrDescriptor?: string | number
13) =>
14(error: unknown): PlatformError.PlatformError => {
15 const denoError = error as DenoError
16 let tag: SystemErrorTag = "Unknown"
17
18 switch (denoError?.name) {
19 case "AlreadyExists":
20 tag = "AlreadyExists"
21 break
22 case "NotCapable":
23 tag = "PermissionDenied"
24 break
25 case "BadResource":
26 case "InvalidData":
27 case "TimedOut":
28 case "UnexpectedEof":
29 case "WouldBlock":
30 case "WriteZero":
31 tag = denoError.name
32 break
33 default:
34 switch (denoError?.code) {
35 case "ENOENT":
36 tag = "NotFound"
37 break
38
39 case "EACCES":
40 tag = "PermissionDenied"
41 break
42
43 case "EEXIST":
44 tag = "AlreadyExists"
45 break
46
47 case "EISDIR":
48 case "ENOTDIR":
49 case "ELOOP":
50 tag = "BadResource"
51 break
52
53 case "EBUSY":
54 tag = "Busy"
55 break
56 }
57 }
58
59 return PlatformError.systemError({
60 _tag: tag,
61 module,
62 method,
63 pathOrDescriptor,
64 cause: error
65 })
66}

Callers 7

error.test.tsFile · 0.90
outputFunction · 0.90
DenoStdio.tsFile · 0.90
tryPromiseFunction · 0.90
closeFunction · 0.90
collectAsyncIterableFunction · 0.90
watchNativeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected