feat(validation): ValidationError → 422 with source + issues (before HttpError)

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-06 21:29:27 -05:00
1 parent 81dc9d3a70
commit 101833d52d
3 files changed
+40 -3

No files matched your search

+8
View File
@@ -1,3 +1,5 @@
import type { StandardIssue } from './standard-schema';
export class HttpError extends Error {
constructor(readonly status: number, message?: string, readonly body?: unknown) {
super(message ?? `HTTP ${status}`);
@@ -21,6 +23,12 @@ export class Redirect extends HttpError {
constructor(readonly location: string) { super(302); }
}
export class ValidationError extends HttpError {
constructor(public issues: StandardIssue[], public source: string) {
super(422, 'Validation failed');
}
}
export function isHttpError(e: unknown): e is HttpError {
return e instanceof HttpError;
}