Skip to content

Commit

Permalink
Re-throw axios errors to be used in the sagas
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Nov 11, 2022
1 parent 5231fd9 commit f49efac
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions assets/js/lib/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const post = function (url, data) {
.post(url, data, conf)
.then(handleResponseStatus)
.catch((error) => {
logError(error);
handleError(error);
});
};

Expand All @@ -21,7 +21,7 @@ export const del = function (url) {
.delete(url, conf)
.then(handleResponseStatus)
.catch((error) => {
logError(error);
handleError(error);
});
};

Expand All @@ -30,7 +30,7 @@ export const put = function (url, data) {
.put(url, data, conf)
.then(handleResponseStatus)
.catch((error) => {
logError(error);
handleError(error);
});
};

Expand All @@ -39,8 +39,7 @@ export const get = function (url) {
.get(url, conf)
.then(handleResponseStatus)
.catch((error) => {
logError(error);
throw error;
handleError(error);
});
};

Expand All @@ -61,3 +60,8 @@ function handleResponseStatus(response) {

return response;
}

function handleError(error) {
logError(error);
throw error;
}

0 comments on commit f49efac

Please sign in to comment.