mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-01 07:28:24 +01:00
Log errors
This commit is contained in:
parent
16bb03c47c
commit
54cd7a32d8
@ -1,7 +1,11 @@
|
|||||||
|
import * as Logger from "../Common/Logger";
|
||||||
|
|
||||||
export function validateEndpoint(endpointToValidate: string | undefined, allowedEndpoints: string[]): boolean {
|
export function validateEndpoint(endpointToValidate: string | undefined, allowedEndpoints: string[]): boolean {
|
||||||
try {
|
try {
|
||||||
return validateEndpointInternal(endpointToValidate, allowedEndpoints);
|
return validateEndpointInternal(endpointToValidate, allowedEndpoints);
|
||||||
} catch {
|
} catch (reason) {
|
||||||
|
Logger.logError(`${endpointToValidate} not allowed`, "validateEndpoint");
|
||||||
|
Logger.logError(`${JSON.stringify(reason)}`, "validateEndpoint");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -16,7 +20,9 @@ function validateEndpointInternal(endpointToValidate: string | undefined, allowe
|
|||||||
const valid = allowedOrigins.indexOf(originToValidate) >= 0;
|
const valid = allowedOrigins.indexOf(originToValidate) >= 0;
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
console.error(`${endpointToValidate} not allowed`);
|
throw new Error(
|
||||||
|
`${endpointToValidate} is not an allowed endpoint. Allowed endpoints are ${allowedArmEndpoints.toString()}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user