Merge pull request #33040 from overleaf/em-parse-req-errors

Replace isZodErrorLike with custom error types in request validation

GitOrigin-RevId: 9cb453a2cde595a00f5049e4829ea9e3dbe17b28
This commit is contained in:
Eric Mc Sween
2026-05-06 08:06:37 +00:00
committed by Copybot
parent 1aa6f03b3c
commit 98def949ec
16 changed files with 100 additions and 80 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
// @ts-check
const { ParamsError } = require('./Errors')
const { InvalidRequestError, InvalidParamsError } = require('./Errors')
/**
* @typedef {import('zod').ZodType} ZodType
@@ -25,9 +25,9 @@ function parseReq(req, schema) {
return parsed.data
} else if (parsed.error.issues.some(issue => issue.path[0] === 'params')) {
// Parts of the URL path failed to validate; throw a specific error
throw new ParamsError('Invalid params').withCause(parsed.error)
throw new InvalidParamsError(parsed.error)
} else {
throw parsed.error
throw new InvalidRequestError(parsed.error)
}
}