@eldev/business-central-api
Version:
A Dynamics 365 Business Central client for TypeScript
54 lines • 2.04 kB
TypeScript
import { type BCErrorCategory, type BCRetryStrategy } from "./categorize.js";
type ODataError = {
code: string;
message: string;
};
/**
* Business Central API Error class
*/
export declare class BCError extends Error {
readonly category: BCErrorCategory;
readonly httpStatus: number;
readonly retryStrategy: BCRetryStrategy;
readonly timestamp: Date;
correlationId?: string;
validationDetails?: {
message: string;
path: string;
}[];
serverError?: ODataError;
responseData?: unknown;
cause?: Error;
constructor(message: string, category: BCErrorCategory, retryStrategy: BCRetryStrategy, httpStatus: number);
isRetryable(): boolean;
isSchemaMismatch(): boolean;
hasValidationDetails(): boolean;
getValidationFields(): string[];
toLogObject(): {
name: string;
message: string;
category: "AUTHENTICATION" | "AUTHORIZATION" | "BAD_REQUEST" | "NOT_FOUND" | "CONFLICT" | "SCHEMA_MISMATCH" | "NETWORK_ERROR" | "UNEXPECTED_RESPONSE" | "SERVER_ERROR" | "UNKNOWN";
httpStatus: number;
retryStrategy: "NO_RETRY" | "EXPONENTIAL_BACKOFF" | "REFRESH_TOKEN";
correlationId: string | undefined;
timestamp: string;
validationDetails: {
message: string;
path: string;
}[] | undefined;
validationCount: number | undefined;
responseData: unknown;
serverError: ODataError | undefined;
};
toSpanAttributes(): Record<string, string | number | boolean>;
static fromHttpResponse(status: number, data: unknown, correlationId: string): BCError;
static fromSchemaValidation(issues: {
message: string;
path: string;
}[], httpStatus?: number): BCError;
static fromUnexpectedResponse(data: unknown, httpStatus: number, correlationId: string, cause?: Error): BCError;
static fromGetToken(err: unknown): BCError;
static fromNetworkError(networkError: Error): BCError;
}
export {};
//# sourceMappingURL=error.d.ts.map