Skip to content

Commit dca4f5b

Browse files
authored
fix(containers): do not crash because of unhandled error (#325)
1 parent 2d33523 commit dca4f5b

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

shared/api/containers.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,15 @@ module.exports = {
113113
return container;
114114
})
115115
.catch((err) => {
116-
// There's no "deleted" status for container,
117-
// so if the container is not found we consider it as deleted and return null
118-
if (err.response.status === 404) {
119-
return null;
116+
// toleration on 4XX errors because on some status, for example deleting the API
117+
// will return a 404 err code if item has been deleted.
118+
if (err.response === undefined) {
119+
// if we have a raw Error
120+
throw err;
121+
} else if (err.response.status >= 500) {
122+
// if we have a CustomError, we can check the status
123+
throw new Error(err);
120124
}
121-
122-
throw new Error(err);
123125
});
124126
},
125127

shared/api/functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ module.exports = {
115115
return func;
116116
})
117117
.catch((err) => {
118-
// toleration on 4XX errors because on some status, for exemple deleting the API
118+
// toleration on 4XX errors because on some status, for example deleting the API
119119
// will return a 404 err code if item has been deleted.
120120
if (err.response === undefined) {
121121
// if we have a raw Error

0 commit comments

Comments
 (0)