Skip to content

Commit bbbd084

Browse files
mstierankavallpaper
authored andcommitted
Fix TimeoutError handling - closes #26
1 parent 26792c2 commit bbbd084

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lib/api-client.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,21 @@ class ApiClient {
6060
return resolve(response);
6161
});
6262
})
63-
.catch((error) => {
64-
return error.response.text().then((body) => {
65-
if (error instanceof ky.HTTPError) {
66-
error = new api_errors.ResponseError(
67-
request,
68-
error.response.status,
69-
body
70-
);
71-
} else if (error instanceof ky.TimeoutError) {
72-
error = new api_errors.TimeoutError(request, error);
73-
}
74-
if (callback) {
75-
return callback(error);
76-
}
77-
throw error;
78-
});
79-
});
63+
.catch(async (error) => {
64+
if (error instanceof ky.TimeoutError) {
65+
error = new api_errors.TimeoutError(request, error);
66+
} else if (error instanceof ky.HTTPError) {
67+
error = new api_errors.ResponseError(
68+
request,
69+
error.response.status,
70+
await error.response.text()
71+
);
72+
}
73+
if (callback) {
74+
return callback(error);
75+
}
76+
throw error;
77+
});
8078
})
8179
}
8280

0 commit comments

Comments
 (0)