Skip to content

Commit

Permalink
resolved PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjeevLakhwani committed Jul 10, 2023
1 parent 97791c5 commit 43d9c75
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/utils/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ const _paginatedNetworkFetch = async (url, baseUrl, req, parse) => {
const _fetchNext = async (pageUrl) => {
const response = await fetch(pageUrl, req);
if (!response.ok) {
const errorData = await parse(response);
throw new Error(errorData.message || "Invalid response encountered");
try {
const errorData = await parse(response);
throw new Error(errorData.message);
} catch (_) {
throw new Error("Invalid response encountered");
}
}

const data = await parse(response);
Expand Down Expand Up @@ -100,7 +104,7 @@ const _networkAction =
});
if (onSuccess) await onSuccess(data);
} catch (e) {
const errorMsg = e.message || err;
const errorMsg = err + (e.message ? `: ${e.message}` : "");
console.error(e, errorMsg);
message.error(errorMsg);
dispatch({ type: types.ERROR, ...params, caughtError: e });
Expand Down

0 comments on commit 43d9c75

Please sign in to comment.