mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user