fix(server): convert 4xx status HttpError to UserFriendlyError (#10956)

This commit is contained in:
fengmk2
2025-03-18 09:28:50 +00:00
parent 5cb2abab76
commit 86c4e0705f
12 changed files with 78 additions and 6 deletions
@@ -1,6 +1,7 @@
import { type Blob } from '@prisma/client';
import { TestingApp } from './testing-app';
import { TEST_LOG_LEVEL } from './utils';
export async function listBlobs(
app: TestingApp,
@@ -73,5 +74,13 @@ export async function setBlob(
`blob-${Math.random().toString(16).substring(2, 10)}.data`
)
.expect(200);
if (res.body.errors?.length) {
if (TEST_LOG_LEVEL !== 'fatal') {
// print the error stack when log level is not fatal, for better debugging
console.error('%o', res.body);
}
throw new Error(res.body.errors[0].message);
}
return res.body.data.setBlob;
}