diff --git a/src/Common/CosmosClient.ts b/src/Common/CosmosClient.ts index 29a824c65..5a3a849f2 100644 --- a/src/Common/CosmosClient.ts +++ b/src/Common/CosmosClient.ts @@ -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 = 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; } }; diff --git a/src/Common/dataAccess/updateDocument.ts b/src/Common/dataAccess/updateDocument.ts index 25cf99a12..dd97b46de 100644 --- a/src/Common/dataAccess/updateDocument.ts +++ b/src/Common/dataAccess/updateDocument.ts @@ -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 {