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

Function ErrorInstance

packages/effect/src/Schema.ts:9299–9316  ·  view source on GitHub ↗
(options?: ErrorOptions)

Source from the content-addressed store, hash-verified

9297 * @since 4.0.0
9298 */
9299export function ErrorInstance(options?: ErrorOptions): ErrorInstance {
9300 const key = getErrorOptionsKey(options)
9301 const cached = errorSchemaCache[key]
9302 if (cached !== undefined) {
9303 return cached
9304 }
9305 const normalizedOptions = getErrorOptions(key)
9306 const schema = instanceOf(globalThis.Error, {
9307 representation: {
9308 id: "effect/schema/Error",
9309 payload: normalizedOptions ?? null
9310 },
9311 expected: "Error",
9312 toCodecJson: () => link<globalThis.Error>()(JsonError, SchemaTransformation.errorFromJsonError(normalizedOptions))
9313 })
9314 errorSchemaCache[key] = schema
9315 return schema
9316}
9317/**
9318 * Type-level representation of {@link Defect}.
9319 *

Callers

nothing calls this directly

Calls 4

getErrorOptionsKeyFunction · 0.85
getErrorOptionsFunction · 0.85
instanceOfFunction · 0.70
linkFunction · 0.70

Tested by

no test coverage detected