@overmap-ai/core 1.0.25-fix-api-error-messages.1 → 1.0.25-fix-api-error-messages.3
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.
- package/dist/overmap-core.js +14 -14
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +14 -14
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -3316,7 +3316,6 @@ const defaultStore = configureStore({
|
|
|
3316
3316
|
}
|
|
3317
3317
|
});
|
|
3318
3318
|
async function performRequest(action, client) {
|
|
3319
|
-
var _a2;
|
|
3320
3319
|
async function checkToken() {
|
|
3321
3320
|
if (client.auth.tokenIsExpiringSoon()) {
|
|
3322
3321
|
await client.auth.renewTokens();
|
|
@@ -3410,9 +3409,14 @@ async function performRequest(action, client) {
|
|
|
3410
3409
|
try {
|
|
3411
3410
|
return await requestToSend.query(queryParams);
|
|
3412
3411
|
} catch (error) {
|
|
3412
|
+
console.debug("TYPE OF ERROR:", typeof error, error instanceof Error, error instanceof Response);
|
|
3413
|
+
if (error instanceof Error) {
|
|
3414
|
+
console.error(error.message);
|
|
3415
|
+
}
|
|
3413
3416
|
console.error(error);
|
|
3414
3417
|
const originalError = error;
|
|
3415
|
-
|
|
3418
|
+
const status = originalError["status"];
|
|
3419
|
+
if (status === 401) {
|
|
3416
3420
|
console.debug("Forbidden; renewing tokens and retrying.");
|
|
3417
3421
|
try {
|
|
3418
3422
|
await client.auth.renewTokens();
|
|
@@ -3427,27 +3431,23 @@ async function performRequest(action, client) {
|
|
|
3427
3431
|
} else {
|
|
3428
3432
|
console.warn("No signed-in user to sign out.");
|
|
3429
3433
|
}
|
|
3430
|
-
throw new APIError("You have been signed out due to inactivity.", originalError, {
|
|
3434
|
+
throw new APIError("You have been signed out due to inactivity.", originalError, {
|
|
3435
|
+
discard: true
|
|
3436
|
+
});
|
|
3431
3437
|
}
|
|
3432
3438
|
}
|
|
3433
|
-
const
|
|
3434
|
-
|
|
3435
|
-
"API error:",
|
|
3436
|
-
originalError,
|
|
3437
|
-
originalError.error,
|
|
3438
|
-
originalError.text,
|
|
3439
|
-
originalError.body,
|
|
3440
|
-
originalError.status
|
|
3441
|
-
);
|
|
3439
|
+
const members = ["message", "text", "body", "error"];
|
|
3440
|
+
const apiErrorMessage = members.map((member) => originalError[member]).find((member) => member !== void 0);
|
|
3442
3441
|
throw new APIError(
|
|
3443
3442
|
typeof apiErrorMessage === "string" ? apiErrorMessage : (
|
|
3444
3443
|
// TODO: Error codes for all APIErrors.
|
|
3445
3444
|
// TODO: Constant for all messages.
|
|
3446
|
-
|
|
3445
|
+
"An unexpected error occurred."
|
|
3447
3446
|
),
|
|
3447
|
+
// TODO: Update the type in APIError to accept Error as well, or figure out when it's this or that.
|
|
3448
3448
|
originalError,
|
|
3449
3449
|
{
|
|
3450
|
-
discard: discardStatuses.includes(
|
|
3450
|
+
discard: discardStatuses.includes(status)
|
|
3451
3451
|
}
|
|
3452
3452
|
);
|
|
3453
3453
|
}
|