mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-06 18:07:11 +00:00
Added rough error handling in local requestPlugin used in local environments. Passes new error to calling code.
Might need to add specific error handling for request plugin to the handleError class.
This commit is contained in:
parent
1e9b706d8f
commit
066ebf52d8
@ -4,7 +4,7 @@ import { AuthorizationToken } from "Contracts/FabricMessageTypes";
|
|||||||
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
import { checkDatabaseResourceTokensValidity } from "Platform/Fabric/FabricUtil";
|
||||||
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||||
import { AuthType } from "../AuthType";
|
import { AuthType } from "../AuthType";
|
||||||
import { PriorityLevel } from "../Common/Constants";
|
import { HttpStatusCodes, PriorityLevel } from "../Common/Constants";
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import { Platform, configContext } from "../ConfigContext";
|
import { Platform, configContext } from "../ConfigContext";
|
||||||
import { updateUserContext, userContext } from "../UserContext";
|
import { updateUserContext, userContext } from "../UserContext";
|
||||||
@ -12,7 +12,7 @@ import { isDataplaneRbacSupported } from "../Utils/APITypeUtils";
|
|||||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||||
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
||||||
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
||||||
import { getErrorMessage, handleError } from "./ErrorHandlingUtils";
|
import { getErrorMessage } from "./ErrorHandlingUtils";
|
||||||
|
|
||||||
const _global = typeof self === "undefined" ? window : self;
|
const _global = typeof self === "undefined" ? window : self;
|
||||||
|
|
||||||
@ -110,16 +110,17 @@ export const requestPlugin: Cosmos.Plugin<any> = async (requestContext, diagnost
|
|||||||
console.log(`REQUEST CONTEXT ENDPOINT: ${JSON.stringify(requestContext.endpoint)}`);
|
console.log(`REQUEST CONTEXT ENDPOINT: ${JSON.stringify(requestContext.endpoint)}`);
|
||||||
requestContext.headers["x-ms-proxy-target"] = endpoint();
|
requestContext.headers["x-ms-proxy-target"] = endpoint();
|
||||||
console.log(`REQUEST CONTEXT PROXY: ${JSON.stringify(requestContext.headers["x-ms-proxy-target"])}`);
|
console.log(`REQUEST CONTEXT PROXY: ${JSON.stringify(requestContext.headers["x-ms-proxy-target"])}`);
|
||||||
// return next(requestContext);
|
// Try request. Catch known errors and rethrow in format that can be handled by the calling code.
|
||||||
// Don't re-throw error so the SDK sees a completed request with the error.
|
|
||||||
// Maybe only re-throw unknown errors?
|
|
||||||
try {
|
try {
|
||||||
return await next(requestContext);
|
return await next(requestContext);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Caught in proxy.`);
|
if (
|
||||||
console.log(error);
|
error?.message.indexOf("The requested operation cannot be performed at this region") >= 0 &&
|
||||||
handleError(error, "ProxyRequest", "Failed to proxy request.");
|
error.code === HttpStatusCodes.Forbidden
|
||||||
// throw error;
|
) {
|
||||||
|
throw new Error("Request Plugin: 403 Forbidden in Operation for Region: " + error.message);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,8 +32,6 @@ export const updateDocument = async (
|
|||||||
logConsoleInfo(`Successfully updated ${entityName} ${documentId.id()}`);
|
logConsoleInfo(`Successfully updated ${entityName} ${documentId.id()}`);
|
||||||
return response?.resource;
|
return response?.resource;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(`Caught in client update call.`);
|
|
||||||
console.log(error);
|
|
||||||
handleError(error, "UpdateDocument", `Failed to update ${entityName} ${documentId.id()}`);
|
handleError(error, "UpdateDocument", `Failed to update ${entityName} ${documentId.id()}`);
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user