@mattrglobal/verifier-sdk-web 1.1.1-unstable.171 → 1.1.1-unstable.173

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1678,10 +1678,29 @@ const safeFetch = async (input, init) => {
1678
1678
  const response = await fetch(input, Object.assign(Object.assign({}, init), {
1679
1679
  headers: headers
1680
1680
  }));
1681
+ const defaultHttpErrorMessage = `HTTP error, status = ${response.status}`;
1682
+ if (response.status >= 400 && response.status < 500) {
1683
+ try {
1684
+ const errorBody = await response.json();
1685
+ if (typeof (errorBody === null || errorBody === void 0 ? void 0 : errorBody.message) === "string") {
1686
+ return err({
1687
+ type: SafeFetchErrorType.HttpError,
1688
+ message: errorBody.message,
1689
+ status: response.status
1690
+ });
1691
+ }
1692
+ } catch (_a) {
1693
+ return err({
1694
+ type: SafeFetchErrorType.HttpError,
1695
+ message: defaultHttpErrorMessage,
1696
+ status: response.status
1697
+ });
1698
+ }
1699
+ }
1681
1700
  if (response.status > 299 || response.status < 200) {
1682
1701
  return err({
1683
1702
  type: SafeFetchErrorType.HttpError,
1684
- message: `HTTP error, status = ${response.status}`,
1703
+ message: defaultHttpErrorMessage,
1685
1704
  status: response.status
1686
1705
  });
1687
1706
  }