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

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.
@@ -343,10 +343,29 @@ const safeFetch = async (input, init) => {
343
343
  const response = await fetch(input, Object.assign(Object.assign({}, init), {
344
344
  headers: headers
345
345
  }));
346
+ const defaultHttpErrorMessage = `HTTP error, status = ${response.status}`;
347
+ if (response.status >= 400 && response.status < 500) {
348
+ try {
349
+ const errorBody = await response.json();
350
+ if (typeof (errorBody === null || errorBody === void 0 ? void 0 : errorBody.message) === "string") {
351
+ return neverthrow.err({
352
+ type: SafeFetchErrorType.HttpError,
353
+ message: errorBody.message,
354
+ status: response.status
355
+ });
356
+ }
357
+ } catch (_a) {
358
+ return neverthrow.err({
359
+ type: SafeFetchErrorType.HttpError,
360
+ message: defaultHttpErrorMessage,
361
+ status: response.status
362
+ });
363
+ }
364
+ }
346
365
  if (response.status > 299 || response.status < 200) {
347
366
  return neverthrow.err({
348
367
  type: SafeFetchErrorType.HttpError,
349
- message: `HTTP error, status = ${response.status}`,
368
+ message: defaultHttpErrorMessage,
350
369
  status: response.status
351
370
  });
352
371
  }