From d2e6e1fd5b6a92cacdbc4d353ce27573a81ef6d5 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Sat, 6 May 2023 10:17:25 +0800 Subject: [PATCH] fix(core): use correct status code for slonik errors (#3812) --- packages/core/src/middleware/koa-slonik-error-handler.test.ts | 2 ++ packages/core/src/middleware/koa-slonik-error-handler.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/core/src/middleware/koa-slonik-error-handler.test.ts b/packages/core/src/middleware/koa-slonik-error-handler.test.ts index 6c189a4a2..0c786a27a 100644 --- a/packages/core/src/middleware/koa-slonik-error-handler.test.ts +++ b/packages/core/src/middleware/koa-slonik-error-handler.test.ts @@ -46,6 +46,7 @@ describe('koaSlonikErrorHandler middleware', () => { await expect(koaSlonikErrorHandler()(ctx, next)).rejects.toMatchError( new RequestError({ code: 'entity.create_failed', + status: 422, name: Users.tableSingular, }) ); @@ -64,6 +65,7 @@ describe('koaSlonikErrorHandler middleware', () => { await expect(koaSlonikErrorHandler()(ctx, next)).rejects.toMatchError( new RequestError({ code: 'entity.not_exists', + status: 404, name: Users.tableSingular, }) ); diff --git a/packages/core/src/middleware/koa-slonik-error-handler.ts b/packages/core/src/middleware/koa-slonik-error-handler.ts index 0cd22504b..ad470a506 100644 --- a/packages/core/src/middleware/koa-slonik-error-handler.ts +++ b/packages/core/src/middleware/koa-slonik-error-handler.ts @@ -38,6 +38,7 @@ export default function koaSlonikErrorHandler(): Middleware).schema.tableSingular, @@ -47,6 +48,7 @@ export default function koaSlonikErrorHandler(): Middleware).schema.tableSingular,