MCPcopy
hub / github.com/simstudioai/sim / toError

Function toError

packages/utils/src/errors.ts:5–9  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

3 * Replaces the common `e instanceof Error ? e : new Error(String(e))` pattern in catch clauses.
4 */
5export function toError(value: unknown): Error {
6 if (value instanceof Error) return value
7 if (typeof value === 'string') return new Error(value)
8 return new Error(String(value))
9}
10
11/**
12 * Extracts a string message from an unknown caught value.

Callers 15

executeWithRetryFunction · 0.90
handleBodySizeLimitErrorFunction · 0.90
readToolResponseBodyFunction · 0.90
executeToolFunction · 0.90
executeToolRequestFunction · 0.90
executeMcpToolFunction · 0.90
discover.tsFile · 0.90
parser.tsFile · 0.90
read_page.tsFile · 0.90
create_list.tsFile · 0.90
parseMem0MessagesFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected