diff --git a/server/logging/sentry.ts b/server/logging/sentry.ts index 6a35d5bd5..ed07e259f 100644 --- a/server/logging/sentry.ts +++ b/server/logging/sentry.ts @@ -14,6 +14,7 @@ if (env.SENTRY_DSN) { // Validation "BadRequestError", "SequelizeValidationError", + "SequelizeEmptyResultError", "ValidationError", // Authentication diff --git a/server/middlewares/errorHandling.ts b/server/middlewares/errorHandling.ts index 6ee30234e..1b5faa3db 100644 --- a/server/middlewares/errorHandling.ts +++ b/server/middlewares/errorHandling.ts @@ -1,6 +1,6 @@ import { Context, Next } from "koa"; import { snakeCase } from "lodash"; -import { ValidationError } from "sequelize"; +import { ValidationError, EmptyResultError } from "sequelize"; export default function errorHandling() { return async function errorHandlingMiddleware(ctx: Context, next: Next) { @@ -20,7 +20,8 @@ export default function errorHandling() { } } - if (message.match(/Not found/i)) { + if (err instanceof EmptyResultError || message.match(/Not found/i)) { + message = "Resource not found"; ctx.status = 404; error = "not_found"; }