From 10db0d11eb757c43a19bbbb6dd0123a0dfc42418 Mon Sep 17 00:00:00 2001 From: xudaotutou <13435638964@163.com> Date: Fri, 10 Jan 2025 16:09:25 +0800 Subject: [PATCH] fix(devbox): fix show error --- .../devbox/services/backend/response.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/providers/devbox/services/backend/response.ts b/frontend/providers/devbox/services/backend/response.ts index b78b5f1c362..44254e8ddd9 100644 --- a/frontend/providers/devbox/services/backend/response.ts +++ b/frontend/providers/devbox/services/backend/response.ts @@ -15,13 +15,21 @@ export const jsonRes = (props: { return NextResponse.json(ERROR_RESPONSE[error]) } const body = error?.body - if(body instanceof V1Status && body.message?.includes('40001:')) { - return NextResponse.json(ERROR_RESPONSE[ERROR_ENUM.outstandingPayment]) + if (body instanceof V1Status) { + if (body.message?.includes('40001:')) { + return NextResponse.json(ERROR_RESPONSE[ERROR_ENUM.outstandingPayment]) + } else { + return NextResponse.json({ + code: 500, + statusText: body.message, + message: body.message, + }) + } } let msg = message if ((code < 200 || code >= 400) && !message) { - if(code >= 500) { + if (code >= 500) { console.log(error) msg = 'Internal Server Error' } else { @@ -34,7 +42,7 @@ export const jsonRes = (props: { } console.log('===jsonRes===\n', error) } - if(code >= 500) { + if (code >= 500) { return NextResponse.json({ code, statusText: '',