🌟 Improvement 🌟
- Implement
.errors
in every builder, allowing you to define error handling at a global or granular level for enhanced reusability and flexibility. - Middleware use before .input/.output will be execute before/after validation step
const pub = os.errors({
UNAUTHORIZED: {},
}).use(({ errors }) => {
throw errors.UNAUTHORIZED()
})
const getting = pub
.input(z.object({ id: z.string() }))
.errors({
NOT_FOUND: {
message: 'User not found',
},
})
.handler(({ errors }) => {
throw errors.NOT_FOUND()
throw errors.UNAUTHORIZED()
// ...
})