Skip to content

Commit a8d0f56

Browse files
committed
Update poolApiService.ts
1 parent 0816f09 commit a8d0f56

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

apps/box/src/services/poolApiService.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,21 @@ export class PoolApiService {
5454
}
5555

5656
if (!response.ok) {
57-
return {
58-
status: 'err',
59-
msg: `HTTP error! status: ${response.status}`,
60-
};
57+
// Try to parse the error body — the server returns { status, msg, errors? }
58+
try {
59+
const errorData: JoinPoolResponse = await response.json();
60+
if (errorData.errors?.length) {
61+
errorData.msg = errorData.errors
62+
.map((e) => `${e.field}: ${e.message}`)
63+
.join('; ');
64+
}
65+
return errorData;
66+
} catch {
67+
return {
68+
status: 'err',
69+
msg: `HTTP error! status: ${response.status}`,
70+
};
71+
}
6172
}
6273

6374
const data: JoinPoolResponse = await response.json();

0 commit comments

Comments
 (0)