MCPcopy
hub / github.com/brimdata/zui / errorToString

Function errorToString

apps/zui/src/util/error-to-string.ts:1–25  ·  view source on GitHub ↗
(e: unknown)

Source from the content-addressed store, hash-verified

1export function errorToString(e: unknown) {
2 if (e === null) return ""
3
4 if (e === undefined) return ""
5
6 if (e instanceof Error) {
7 return e.message
8 }
9
10 if (typeof e === "string") {
11 return e
12 }
13
14 if (typeof e === "object") {
15 if ("error" in e && typeof e.error == "string") {
16 return e.error
17 } else if ("message" in e && typeof e.message === "string") {
18 return e.message
19 }
20 }
21
22 if (e && e.toString) return e.toString()
23
24 return JSON.stringify(e)
25}

Callers 10

ErrorLinesFunction · 0.90
operations.tsFile · 0.90
runMethod · 0.90
create.tsFile · 0.90
export.tsFile · 0.90
useZqFunction · 0.90
humanizeErrorFunction · 0.90
humanizeFormErrorMethod · 0.90
useTemplateFunction · 0.90
startPipelineMethod · 0.90

Calls 2

toStringMethod · 0.65
stringifyMethod · 0.45

Tested by

no test coverage detected