Improve error handling

This commit is contained in:
Tom Moor
2018-11-03 21:47:46 -07:00
parent 21b1c0747c
commit 6418712c47
5 changed files with 27 additions and 8 deletions

View File

@@ -68,6 +68,14 @@ class ApiClient {
const error = {};
error.statusCode = response.status;
error.response = response;
try {
const data = await response.json();
error.message = data.message || '';
} catch (_err) {
// we're trying to parse an error so JSON may not be valid
}
throw error;
};