Remove Zod from named errors (#26982)
This commit is contained in:
@@ -2,7 +2,6 @@ export * as ConfigParse from "./parse"
|
||||
|
||||
import { type ParseError as JsoncParseError, parse as parseJsoncImpl, printParseErrorCode } from "jsonc-parser"
|
||||
import { Cause, Exit, Schema as EffectSchema, SchemaIssue } from "effect"
|
||||
import type z from "zod"
|
||||
import type { DeepMutable } from "@opencode-ai/core/schema"
|
||||
import { InvalidError, JsonError } from "./error"
|
||||
|
||||
@@ -48,7 +47,7 @@ export function schema<S extends EffectSchema.Decoder<unknown, never>>(
|
||||
keys: extra,
|
||||
path: [],
|
||||
message: `Unrecognized key${extra.length === 1 ? "" : "s"}: ${extra.join(", ")}`,
|
||||
} as z.core.$ZodIssue,
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
@@ -61,8 +60,12 @@ export function schema<S extends EffectSchema.Decoder<unknown, never>>(
|
||||
{
|
||||
path: source,
|
||||
issues: EffectSchema.isSchemaError(error)
|
||||
? (SchemaIssue.makeFormatterStandardSchemaV1()(error.issue).issues as z.core.$ZodIssue[])
|
||||
: ([{ code: "custom", message: String(error), path: [] }] as z.core.$ZodIssue[]),
|
||||
? SchemaIssue.makeFormatterStandardSchemaV1()(error.issue).issues.map((issue) => ({
|
||||
...issue,
|
||||
message: issue.message,
|
||||
path: issue.path?.map(String) ?? [],
|
||||
}))
|
||||
: [{ message: String(error), path: [] }],
|
||||
},
|
||||
{ cause: error },
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user