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

Function makeEncodeDefect

packages/effect/src/SchemaTransformation.ts:1121–1136  ·  view source on GitHub ↗
(options?: ErrorOptions)

Source from the content-addressed store, hash-verified

1119}
1120
1121const makeEncodeDefect = (options?: ErrorOptions): (input: unknown) => Json => {
1122 const seen = new WeakSet<object>()
1123 const encode = (input: unknown): Json => {
1124 if (Predicate.isError(input)) {
1125 if (seen.has(input)) {
1126 return "[Circular]"
1127 }
1128 seen.add(input)
1129 const encoded = encodeJsonError(input, options, encode)
1130 seen.delete(input)
1131 return encoded
1132 }
1133 return encodeUnknownAsJson(input)
1134 }
1135 return encode
1136}
1137
1138const decodeDefect = (input: Json): unknown => isJsonError(input) ? decodeJsonError(input) : input
1139

Callers 2

errorFromJsonErrorFunction · 0.85
defectFromJsonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected