mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Merge pull request #33490 from overleaf/em-parse-req-errors-2
Reintroduce custom error types in request validation GitOrigin-RevId: 1985ca04c8fe693fb836b042517d94700343bc46
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