MCPcopy
hub / github.com/FlowiseAI/Flowise / toErrorWithMessage

Function toErrorWithMessage

packages/server/src/errors/utils.ts:11–21  ·  view source on GitHub ↗
(maybeError: unknown)

Source from the content-addressed store, hash-verified

9}
10
11const toErrorWithMessage = (maybeError: unknown): ErrorWithMessage => {
12 if (isErrorWithMessage(maybeError)) return maybeError
13
14 try {
15 return new Error(JSON.stringify(maybeError))
16 } catch {
17 // fallback in case there's an error stringifying the maybeError
18 // like with circular references for example.
19 return new Error(String(maybeError))
20 }
21}
22
23export const getErrorMessage = (error: unknown) => {
24 return toErrorWithMessage(error).message

Callers 1

getErrorMessageFunction · 0.70

Calls 2

stringifyMethod · 0.80
isErrorWithMessageFunction · 0.70

Tested by

no test coverage detected