Skip to content

Commit bd3ea4e

Browse files
committed
fix(api): improve error handling with status code in error
1 parent a1b34e3 commit bd3ea4e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@squarecloud/api": patch
3+
---
4+
5+
Show response status at unknown API errors

src/services/api.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export class APIService {
4747
});
4848

4949
if (!data || data.status === "error" || !response.ok) {
50-
throw new SquareCloudAPIError(data?.code || "COMMON_ERROR");
50+
throw new SquareCloudAPIError(
51+
data?.code || `UNKNOWN_ERROR_${response.status}`,
52+
);
5153
}
5254

5355
return data;

0 commit comments

Comments
 (0)