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:
@@ -13,8 +13,10 @@ import methodOverride from 'method-override'
|
||||
import { mongoClient } from './app/js/mongodb.js'
|
||||
import NotificationsController from './app/js/NotificationsController.ts'
|
||||
import HealthCheckController from './app/js/HealthCheckController.ts'
|
||||
import { isZodErrorLike } from 'zod-validation-error'
|
||||
import { ParamsError } from '@overleaf/validation-tools'
|
||||
import {
|
||||
InvalidParamsError,
|
||||
InvalidRequestError,
|
||||
} from '@overleaf/validation-tools'
|
||||
|
||||
const app = express()
|
||||
|
||||
@@ -56,10 +58,10 @@ const handleApiError: ErrorRequestHandler = (
|
||||
next: NextFunction
|
||||
) => {
|
||||
req.logger.addFields({ err })
|
||||
if (err instanceof ParamsError) {
|
||||
if (err instanceof InvalidParamsError) {
|
||||
req.logger.setLevel('warn')
|
||||
res.sendStatus(404)
|
||||
} else if (isZodErrorLike(err)) {
|
||||
} else if (err instanceof InvalidRequestError) {
|
||||
req.logger.setLevel('warn')
|
||||
res.sendStatus(400)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user