diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/api/client.test.ts | 6 | ||||
| -rw-r--r-- | src/client/api/client.ts | 5 | ||||
| -rw-r--r-- | src/client/api/types.ts | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/client/api/client.test.ts b/src/client/api/client.test.ts index 16deb28..5489547 100644 --- a/src/client/api/client.test.ts +++ b/src/client/api/client.test.ts @@ -85,8 +85,10 @@ describe("ApiClient", () => { { status: 401, body: { - error: "Invalid username or password", - code: "INVALID_CREDENTIALS", + error: { + message: "Invalid username or password", + code: "INVALID_CREDENTIALS", + }, }, }, ]); diff --git a/src/client/api/client.ts b/src/client/api/client.ts index 36a7431..7741942 100644 --- a/src/client/api/client.ts +++ b/src/client/api/client.ts @@ -66,9 +66,10 @@ export class ApiClient { if (!response.ok) { const errorBody = (await response.json().catch(() => ({}))) as ApiError; throw new ApiClientError( - errorBody.error || `Request failed with status ${response.status}`, + errorBody.error?.message || + `Request failed with status ${response.status}`, response.status, - errorBody.code, + errorBody.error?.code, ); } diff --git a/src/client/api/types.ts b/src/client/api/types.ts index d5df182..eaf69eb 100644 --- a/src/client/api/types.ts +++ b/src/client/api/types.ts @@ -10,8 +10,10 @@ export interface AuthResponse { } export interface ApiError { - error: string; - code?: string; + error: { + message: string; + code: string; + }; } export interface Tokens { |
