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

Function decodeJsonError

packages/effect/src/SchemaTransformation.ts:1084–1092  ·  view source on GitHub ↗
(input: JsonError)

Source from the content-addressed store, hash-verified

1082 Predicate.isObject(input) && typeof input["message"] === "string"
1083
1084const decodeJsonError = (input: JsonError): Error => {
1085 const hasCause = Object.hasOwn(input, "cause")
1086 const err = hasCause
1087 ? new Error(input.message, { cause: decodeDefect(input.cause as Json) })
1088 : new Error(input.message)
1089 if (typeof input.name === "string" && input.name !== "Error") err.name = input.name
1090 if (typeof input.stack === "string") err.stack = input.stack
1091 return err
1092}
1093
1094const encodeUnknownAsJson = (input: unknown): Json => {
1095 try {

Callers 1

decodeDefectFunction · 0.85

Calls 1

decodeDefectFunction · 0.85

Tested by

no test coverage detected