@ritas-inc/hanaqueryapi-client
Version:
TypeScript client for HANA Query API with full type safety and error handling
94 lines • 3.4 kB
TypeScript
/**
* HANA Query API Client - Error Classes
*
* Custom error classes for different types of client errors.
*/
import type { ClientErrorType, ClientErrorDetails, ProblemDetails, RequestContext } from './types.ts';
/**
* Base client error class
*/
export declare class HanaQueryClientError extends Error {
readonly type: ClientErrorType;
readonly statusCode?: number;
readonly originalError?: Error;
readonly context?: RequestContext;
readonly problemDetails?: ProblemDetails;
constructor(details: ClientErrorDetails);
/**
* Convert error to JSON for logging/serialization
*/
toJSON(): Record<string, any>;
/**
* Get a human-readable description of the error
*/
getDescription(): string;
}
/**
* Network-related errors (connection failures, timeouts, etc.)
*/
export declare class NetworkError extends HanaQueryClientError {
constructor(message: string, originalError?: Error, context?: RequestContext);
}
/**
* Request timeout errors
*/
export declare class TimeoutError extends HanaQueryClientError {
constructor(timeout: number, context?: RequestContext);
}
/**
* Validation errors (invalid parameters, etc.)
*/
export declare class ValidationError extends HanaQueryClientError {
constructor(message: string, issues?: string[], context?: RequestContext);
}
/**
* Authorization errors (401, 403)
*/
export declare class AuthorizationError extends HanaQueryClientError {
constructor(message: string, statusCode: number, context?: RequestContext);
}
/**
* Not found errors (404)
*/
export declare class NotFoundError extends HanaQueryClientError {
constructor(resource: string, context?: RequestContext);
}
/**
* Server errors (5xx)
*/
export declare class ServerError extends HanaQueryClientError {
constructor(message: string, statusCode: number, problemDetails?: ProblemDetails, context?: RequestContext);
}
/**
* Unknown/unexpected errors
*/
export declare class UnknownError extends HanaQueryClientError {
constructor(message: string, originalError?: Error, context?: RequestContext);
}
/**
* Create appropriate error from HTTP response
*/
export declare function createErrorFromResponse(response: Response, responseData: any, context?: RequestContext): HanaQueryClientError;
/**
* Create error from network/fetch failure
*/
export declare function createNetworkError(error: Error, context?: RequestContext): HanaQueryClientError;
/**
* Check if an error is retryable
*/
export declare function isRetryableError(error: HanaQueryClientError): boolean;
/**
* Get retry delay for an error (exponential backoff)
*/
export declare function getRetryDelay(attempt: number, baseDelay: number, maxDelay: number, backoffMultiplier?: number): number;
/**
* Type guards for specific error types
*/
export declare function isNetworkError(error: any): error is NetworkError;
export declare function isTimeoutError(error: any): error is TimeoutError;
export declare function isValidationError(error: any): error is ValidationError;
export declare function isAuthorizationError(error: any): error is AuthorizationError;
export declare function isNotFoundError(error: any): error is NotFoundError;
export declare function isServerError(error: any): error is ServerError;
export declare function isHanaQueryClientError(error: any): error is HanaQueryClientError;
//# sourceMappingURL=errors.d.ts.map