Skip to content

Commit 2ef66d9

Browse files
committed
fix: error handling for network connection
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent 3878ee1 commit 2ef66d9

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

src/renderer/utils/api/errors.ts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,26 @@ export function determineFailureType(
2929
if (err instanceof RequestError) {
3030
const status = err.status;
3131

32-
if (status === 401) {
33-
return Errors.BAD_CREDENTIALS;
34-
}
35-
36-
if (status === 403) {
37-
if (message.includes("Missing the 'notifications' scope")) {
38-
return Errors.MISSING_SCOPES;
39-
}
40-
41-
if (
42-
message.includes('API rate limit exceeded') ||
43-
message.includes('You have exceeded a secondary rate limit')
44-
) {
45-
return Errors.RATE_LIMITED;
46-
}
47-
}
48-
49-
if (status === 500) {
50-
return Errors.NETWORK;
32+
switch (status) {
33+
case 401:
34+
return Errors.BAD_CREDENTIALS;
35+
case 403:
36+
if (message.includes("Missing the 'notifications' scope")) {
37+
return Errors.MISSING_SCOPES;
38+
}
39+
40+
if (
41+
message.includes('API rate limit exceeded') ||
42+
message.includes('You have exceeded a secondary rate limit')
43+
) {
44+
return Errors.RATE_LIMITED;
45+
}
46+
47+
break;
48+
case 500:
49+
return Errors.NETWORK;
50+
default:
51+
break;
5152
}
5253
}
5354

0 commit comments

Comments
 (0)