@overmap-ai/core 1.0.49-fix-error-messaging.0 → 1.0.49-fix-error-messaging.2

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.
@@ -4538,7 +4538,20 @@ var __publicField = (obj, key, value) => {
4538
4538
  }
4539
4539
  };
4540
4540
  const errorHandler = (error2) => {
4541
- error2.options.discard = true;
4541
+ if (error2 instanceof APIError) {
4542
+ error2.options.discard = true;
4543
+ } else {
4544
+ console.error(
4545
+ "Received an unexpected error while processing a request:",
4546
+ error2,
4547
+ "\nConverting error to APIError and discarding."
4548
+ );
4549
+ error2 = new APIError({
4550
+ message: "An error occurred while processing the request.",
4551
+ innerError: error2,
4552
+ discard: true
4553
+ });
4554
+ }
4542
4555
  promise.reject(error2);
4543
4556
  };
4544
4557
  innerPromise.then(successOrUndefinedHandler, errorHandler);
@@ -5118,24 +5131,22 @@ var __publicField = (obj, key, value) => {
5118
5131
  */
5119
5132
  __publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
5120
5133
  const uuid$1 = uuid.v4();
5121
- try {
5122
- const responsePromise = this.enqueueRequest({
5123
- uuid: uuid$1,
5124
- description: "Get token pair",
5125
- method: HttpMethod.POST,
5126
- url: "/api/token/",
5127
- payload: credentials,
5128
- isAuthNeeded: false,
5129
- blockers: [],
5130
- blocks: []
5131
- });
5132
- return [responsePromise.then(parseTokens), uuid$1];
5133
- } catch (e) {
5134
+ const responsePromise = this.enqueueRequest({
5135
+ uuid: uuid$1,
5136
+ description: "Get token pair",
5137
+ method: HttpMethod.POST,
5138
+ url: "/api/token/",
5139
+ payload: credentials,
5140
+ isAuthNeeded: false,
5141
+ blockers: [],
5142
+ blocks: []
5143
+ }).then(parseTokens).catch((e) => {
5134
5144
  if (logoutOnFailure) {
5135
5145
  void this.logout().then();
5136
5146
  }
5137
5147
  throw e;
5138
- }
5148
+ });
5149
+ return [responsePromise, uuid$1];
5139
5150
  });
5140
5151
  /**
5141
5152
  * Takes refresh token and gets a new token pair
@@ -5196,7 +5207,7 @@ var __publicField = (obj, key, value) => {
5196
5207
  timedOut = true;
5197
5208
  store.dispatch(markForDeletion(uuid$1));
5198
5209
  store.dispatch(markForDeletion(initialDataUuid));
5199
- reject(new Error(`Request timed out after ${timeout} seconds`));
5210
+ reject(new APIError({ message: `Request timed out after ${timeout} seconds` }));
5200
5211
  }, timeout * 1e3);
5201
5212
  });
5202
5213
  const successPromise = promise.then((tokens) => {