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 { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||
import { AuthType } from "../AuthType";
|
||||
import { PriorityLevel } from "../Common/Constants";
|
||||
import { HttpStatusCodes, PriorityLevel } from "../Common/Constants";
|
||||
import * as Logger from "../Common/Logger";
|
||||
import { Platform, configContext } from "../ConfigContext";
|
||||
import { updateUserContext, userContext } from "../UserContext";
|
||||
@ -12,7 +12,7 @@ import { isDataplaneRbacSupported } from "../Utils/APITypeUtils";
|
||||
import { logConsoleError } from "../Utils/NotificationConsoleUtils";
|
||||
import * as PriorityBasedExecutionUtils from "../Utils/PriorityBasedExecutionUtils";
|
||||
import { EmulatorMasterKey, HttpHeaders } from "./Constants";
|
||||
import { getErrorMessage, handleError } from "./ErrorHandlingUtils";
|
||||
import { getErrorMessage } from "./ErrorHandlingUtils";
|
||||
|
||||
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)}`);
|
||||
requestContext.headers["x-ms-proxy-target"] = endpoint();
|
||||
console.log(`REQUEST CONTEXT PROXY: ${JSON.stringify(requestContext.headers["x-ms-proxy-target"])}`);
|
||||
// return next(requestContext);
|
||||
// Don't re-throw error so the SDK sees a completed request with the error.
|
||||
// Maybe only re-throw unknown errors?
|
||||
// Try request. Catch known errors and rethrow in format that can be handled by the calling code.
|
||||
try {
|
||||
return await next(requestContext);
|
||||
} catch (error) {
|
||||
console.log(`Caught in proxy.`);
|
||||
console.log(error);
|
||||
handleError(error, "ProxyRequest", "Failed to proxy request.");
|
||||
// throw error;
|
||||
if (
|
||||
error?.message.indexOf("The requested operation cannot be performed at this region") >= 0 &&
|
||||
error.code === HttpStatusCodes.Forbidden
|
||||
) {
|
||||
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()}`);
|
||||
return response?.resource;
|
||||
} catch (error) {
|
||||
console.log(`Caught in client update call.`);
|
||||
console.log(error);
|
||||
handleError(error, "UpdateDocument", `Failed to update ${entityName} ${documentId.id()}`);
|
||||
throw error;
|
||||
} finally {
|
||||
|
Loading…
x
Reference in New Issue
Block a user