mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-03-31 06:58:49 +01:00
phoenix errors added (#1272)
This commit is contained in:
parent
dfd5a7c698
commit
d13b7a50ad
@ -450,21 +450,21 @@ export interface IResponse<T> {
|
|||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IValidationError {
|
export interface IPhoenixError {
|
||||||
message: string;
|
message: string;
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMaxAllocationTimeExceeded extends IValidationError {
|
export interface IMaxAllocationTimeExceeded extends IPhoenixError {
|
||||||
earliestAllocationTimestamp: string;
|
earliestAllocationTimestamp: string;
|
||||||
maxAllocationTimePerDayPerUserInMinutes: string;
|
maxAllocationTimePerDayPerUserInMinutes: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMaxDbAccountsPerUserExceeded extends IValidationError {
|
export interface IMaxDbAccountsPerUserExceeded extends IPhoenixError {
|
||||||
maxSimultaneousConnectionsPerUser: string;
|
maxSimultaneousConnectionsPerUser: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IMaxUsersPerDbAccountExceeded extends IValidationError {
|
export interface IMaxUsersPerDbAccountExceeded extends IPhoenixError {
|
||||||
maxSimultaneousUsersPerDbAccount: string;
|
maxSimultaneousUsersPerDbAccount: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,4 +557,5 @@ export enum PhoenixErrorType {
|
|||||||
AllocationValidationResult = "AllocationValidationResult",
|
AllocationValidationResult = "AllocationValidationResult",
|
||||||
RegionNotServicable = "RegionNotServicable",
|
RegionNotServicable = "RegionNotServicable",
|
||||||
SubscriptionNotAllowed = "SubscriptionNotAllowed",
|
SubscriptionNotAllowed = "SubscriptionNotAllowed",
|
||||||
|
UnknownError = "UnknownError",
|
||||||
}
|
}
|
||||||
|
@ -369,9 +369,6 @@ export default class Explorer {
|
|||||||
});
|
});
|
||||||
useNotebook.getState().setIsAllocating(true);
|
useNotebook.getState().setIsAllocating(true);
|
||||||
connectionInfo = await this.phoenixClient.allocateContainer(provisionData);
|
connectionInfo = await this.phoenixClient.allocateContainer(provisionData);
|
||||||
if (connectionInfo.status !== HttpStatusCodes.OK) {
|
|
||||||
throw new Error(`Received status code: ${connectionInfo?.status}`);
|
|
||||||
}
|
|
||||||
if (!connectionInfo?.data?.notebookServerUrl) {
|
if (!connectionInfo?.data?.notebookServerUrl) {
|
||||||
throw new Error(`NotebookServerUrl is invalid!`);
|
throw new Error(`NotebookServerUrl is invalid!`);
|
||||||
}
|
}
|
||||||
@ -382,6 +379,7 @@ export default class Explorer {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
TelemetryProcessor.traceFailure(Action.PhoenixConnection, {
|
TelemetryProcessor.traceFailure(Action.PhoenixConnection, {
|
||||||
dataExplorerArea: Areas.Notebook,
|
dataExplorerArea: Areas.Notebook,
|
||||||
|
status: error.status,
|
||||||
error: getErrorMessage(error),
|
error: getErrorMessage(error),
|
||||||
errorStack: getErrorStack(error),
|
errorStack: getErrorStack(error),
|
||||||
});
|
});
|
||||||
|
@ -21,9 +21,9 @@ import {
|
|||||||
IMaxDbAccountsPerUserExceeded,
|
IMaxDbAccountsPerUserExceeded,
|
||||||
IMaxUsersPerDbAccountExceeded,
|
IMaxUsersPerDbAccountExceeded,
|
||||||
IPhoenixConnectionInfoResult,
|
IPhoenixConnectionInfoResult,
|
||||||
|
IPhoenixError,
|
||||||
IProvisionData,
|
IProvisionData,
|
||||||
IResponse,
|
IResponse,
|
||||||
IValidationError,
|
|
||||||
PhoenixErrorType,
|
PhoenixErrorType,
|
||||||
} from "../Contracts/DataModels";
|
} from "../Contracts/DataModels";
|
||||||
import { useNotebook } from "../Explorer/Notebook/useNotebook";
|
import { useNotebook } from "../Explorer/Notebook/useNotebook";
|
||||||
@ -59,17 +59,19 @@ export class PhoenixClient {
|
|||||||
body: JSON.stringify(provisionData),
|
body: JSON.stringify(provisionData),
|
||||||
});
|
});
|
||||||
const responseJson = await response?.json();
|
const responseJson = await response?.json();
|
||||||
if (response.status === HttpStatusCodes.Forbidden) {
|
if (response.ok) {
|
||||||
throw new Error(this.ConvertToForbiddenErrorString(responseJson));
|
return {
|
||||||
|
status: response.status,
|
||||||
|
data: responseJson,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return {
|
const phoenixError = responseJson as IPhoenixError;
|
||||||
status: response.status,
|
if (response.status === HttpStatusCodes.Forbidden) {
|
||||||
data: responseJson,
|
throw new Error(this.ConvertToForbiddenErrorString(phoenixError));
|
||||||
};
|
}
|
||||||
|
throw new Error(phoenixError.message);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (response.status === HttpStatusCodes.Forbidden) {
|
error.status = response?.status;
|
||||||
error.status = HttpStatusCodes.Forbidden;
|
|
||||||
}
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +222,7 @@ export class PhoenixClient {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConvertToForbiddenErrorString(jsonData: IValidationError): string {
|
public ConvertToForbiddenErrorString(jsonData: IPhoenixError): string {
|
||||||
const errInfo = jsonData;
|
const errInfo = jsonData;
|
||||||
switch (errInfo?.type) {
|
switch (errInfo?.type) {
|
||||||
case PhoenixErrorType.MaxAllocationTimeExceeded: {
|
case PhoenixErrorType.MaxAllocationTimeExceeded: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user