fix: close marketplace client review findings
This commit is contained in:
1 parent
8dfa542860
commit
1614f7efc1
25 files changed
+1224
-143
No files matched your search
+6
-1
@@ -111,17 +111,22 @@ function telemetryRoute(path: string): string {
|
||||
async function parseResponse<T>(response: Response): Promise<T> {
|
||||
if (!response.ok) {
|
||||
let message = `${response.status} ${response.statusText}`;
|
||||
let backendCode: string | undefined;
|
||||
try {
|
||||
const payload = await response.json() as { error?: string };
|
||||
const payload = await response.json() as { error?: string; code?: unknown };
|
||||
if (payload?.error) {
|
||||
message = payload.error;
|
||||
}
|
||||
if (typeof payload?.code === 'string' && /^[a-z][a-z0-9_]{0,63}$/u.test(payload.code)) {
|
||||
backendCode = payload.code;
|
||||
}
|
||||
} catch {
|
||||
// ignore body parse failure
|
||||
}
|
||||
throw normalizeAppError(new Error(message), {
|
||||
source: 'browser-fallback',
|
||||
status: response.status,
|
||||
...(backendCode ? { backendCode } : {}),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user