mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-08 01:52:33 +00:00
fix(core): log stack trace when schema validation fails (#16401)
This commit is contained in:
parent
7417c869fc
commit
a2634337b8
1 changed files with 8 additions and 1 deletions
|
|
@ -2,7 +2,14 @@ import { z } from "zod"
|
|||
|
||||
export function fn<T extends z.ZodType, Result>(schema: T, cb: (input: z.infer<T>) => Result) {
|
||||
const result = (input: z.infer<T>) => {
|
||||
const parsed = schema.parse(input)
|
||||
let parsed
|
||||
try {
|
||||
parsed = schema.parse(input)
|
||||
} catch (e) {
|
||||
console.trace("schema validation failure stack trace:")
|
||||
throw e
|
||||
}
|
||||
|
||||
return cb(parsed)
|
||||
}
|
||||
result.force = (input: z.infer<T>) => cb(input)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue