mirror of
https://github.com/warmbly/warmbly.git
synced 2026-08-25 08:00:37 +00:00
feat: surface admin api error metadata
Capture backend error codes and request IDs in the admin APIError type so failed admin views can show actionable diagnostics.
This commit is contained in:
@@ -25,12 +25,20 @@ export class SessionExpiredError extends Error {
|
||||
|
||||
export class APIError<T = unknown> extends Error {
|
||||
status: number;
|
||||
// Machine-readable code + request id from the backend's standard error
|
||||
// envelope ({ error, message, code, request_id }). Surfaced in the UI so a
|
||||
// failed page can show exactly what broke instead of a generic message.
|
||||
code?: string;
|
||||
requestId?: string;
|
||||
body?: T;
|
||||
constructor(message: string, status: number, body?: T) {
|
||||
super(message);
|
||||
this.name = "APIError";
|
||||
this.status = status;
|
||||
this.body = body;
|
||||
const b = body as { code?: string; request_id?: string } | undefined;
|
||||
this.code = b?.code;
|
||||
this.requestId = b?.request_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user