/**
 * Comprehensive Error Handling for BaoLife
 * Provides custom exception classes, error decorators, and client error messaging.
 * Ported from Python errors/error_handler.py
 */
export declare const ErrorCodes: {
    readonly GAME_ERROR: "GAME_ERROR";
    readonly SERVER_ERROR: "SERVER_ERROR";
    readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
    readonly INVALID_ACTION: "INVALID_ACTION";
    readonly INVALID_REQUEST: "INVALID_REQUEST";
    readonly INSUFFICIENT_RESOURCES: "INSUFFICIENT_RESOURCES";
    readonly INSUFFICIENT_ENERGY: "INSUFFICIENT_ENERGY";
    readonly INSUFFICIENT_MONEY: "INSUFFICIENT_MONEY";
    readonly INSUFFICIENT_DIAMONDS: "INSUFFICIENT_DIAMONDS";
    readonly NOT_AUTHENTICATED: "NOT_AUTHENTICATED";
    readonly SESSION_EXPIRED: "SESSION_EXPIRED";
    readonly PLAYER_NOT_FOUND: "PLAYER_NOT_FOUND";
    readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED";
    readonly DUPLICATE_TRANSACTION: "DUPLICATE_TRANSACTION";
    readonly VALIDATION_FAILED: "VALIDATION_FAILED";
    readonly INVALID_PRODUCT: "INVALID_PRODUCT";
    readonly PURCHASE_FAILED: "PURCHASE_FAILED";
    readonly CONNECTION_ERROR: "CONNECTION_ERROR";
    readonly WEBSOCKET_ERROR: "WEBSOCKET_ERROR";
    readonly DATABASE_ERROR: "DATABASE_ERROR";
};
export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
/**
 * Base exception class for all game-related errors
 */
export declare class GameError extends Error {
    readonly errorCode: ErrorCode;
    readonly retryPossible: boolean;
    readonly context?: Record<string, unknown>;
    constructor(message: string, errorCode?: ErrorCode, retryPossible?: boolean, context?: Record<string, unknown>);
    toJSON(): Record<string, unknown>;
}
/**
 * Raised when player lacks required resources
 */
export declare class InsufficientResourcesError extends GameError {
    readonly resourceType: string;
    readonly required: number;
    readonly current: number;
    constructor(resourceType: string, required: number, current: number);
}
/**
 * Raised for internal server errors
 */
export declare class ServerError extends GameError {
    readonly originalError?: Error;
    constructor(message: string, originalError?: Error);
}
/**
 * Raised when a player is not found
 */
export declare class PlayerNotFoundError extends GameError {
    readonly playerId: string;
    constructor(playerId: string);
}
/**
 * Raised when an action is invalid
 */
export declare class InvalidActionError extends GameError {
    readonly action: string;
    constructor(action: string, message?: string);
}
/**
 * Raised for validation failures
 */
export declare class ValidationError extends GameError {
    readonly field?: string;
    constructor(message: string, field?: string);
}
/**
 * Raised when rate limit is exceeded
 */
export declare class RateLimitError extends GameError {
    readonly retryAfter?: number;
    constructor(message?: string, retryAfter?: number);
}
/**
 * Raised for database errors
 */
export declare class DatabaseError extends GameError {
    readonly operation?: string;
    constructor(message: string, operation?: string, originalError?: Error);
}
export type SendToClientFn = (playerId: string, message: Record<string, unknown>) => void | Promise<void>;
export interface ErrorHandlerOptions {
    sendToClient?: SendToClientFn;
    logLevel?: 'error' | 'warn' | 'info' | 'debug';
    rethrow?: boolean;
}
export interface ErrorPayload {
    type: 'error';
    errorCode: ErrorCode;
    message: string;
    retryPossible: boolean;
    timestamp: string;
    [key: string]: unknown;
}
/**
 * Format error into a client-friendly payload
 */
export declare function formatErrorForClient(error: GameError): ErrorPayload;
/**
 * Format an unknown error into a client-friendly payload
 */
export declare function formatUnknownErrorForClient(error: unknown): ErrorPayload;
/**
 * Log an error with context
 */
export declare function logError(error: unknown, context?: {
    playerId?: string;
    operation?: string;
    additionalInfo?: Record<string, unknown>;
}): void;
/**
 * Send error to client
 */
export declare function sendErrorToClient(playerId: string, error: GameError | Error | unknown, sendToClient: SendToClientFn): Promise<void>;
/**
 * Decorator for automatic error handling with logging and client notification.
 *
 * Usage:
 * ```typescript
 * const safeHandler = handleErrors(async (playerId: string, amount: number) => {
 *   // ... code that might throw
 * }, { sendToClient: myClientSendFn });
 * ```
 */
export declare function handleErrors<T extends (...args: unknown[]) => Promise<unknown>>(fn: T, options?: ErrorHandlerOptions): (...args: Parameters<T>) => Promise<ReturnType<T> | undefined>;
/**
 * Wrap a sync function with error handling
 */
export declare function handleErrorsSync<T extends (...args: unknown[]) => unknown>(fn: T, options?: Omit<ErrorHandlerOptions, 'sendToClient'>): (...args: Parameters<T>) => ReturnType<T> | undefined;
/**
 * Check if an error is a specific type
 */
export declare function isGameError(error: unknown): error is GameError;
export declare function isInsufficientResourcesError(error: unknown): error is InsufficientResourcesError;
export declare function isServerError(error: unknown): error is ServerError;
export declare function isRateLimitError(error: unknown): error is RateLimitError;
/**
 * Create a simple error response object
 */
export declare function createErrorResponse(errorCode: ErrorCode, message: string, retryPossible?: boolean): ErrorPayload;
export declare const errorHandler: {
    GameError: typeof GameError;
    InsufficientResourcesError: typeof InsufficientResourcesError;
    ServerError: typeof ServerError;
    PlayerNotFoundError: typeof PlayerNotFoundError;
    InvalidActionError: typeof InvalidActionError;
    ValidationError: typeof ValidationError;
    RateLimitError: typeof RateLimitError;
    DatabaseError: typeof DatabaseError;
    ErrorCodes: {
        readonly GAME_ERROR: "GAME_ERROR";
        readonly SERVER_ERROR: "SERVER_ERROR";
        readonly UNEXPECTED_ERROR: "UNEXPECTED_ERROR";
        readonly INVALID_ACTION: "INVALID_ACTION";
        readonly INVALID_REQUEST: "INVALID_REQUEST";
        readonly INSUFFICIENT_RESOURCES: "INSUFFICIENT_RESOURCES";
        readonly INSUFFICIENT_ENERGY: "INSUFFICIENT_ENERGY";
        readonly INSUFFICIENT_MONEY: "INSUFFICIENT_MONEY";
        readonly INSUFFICIENT_DIAMONDS: "INSUFFICIENT_DIAMONDS";
        readonly NOT_AUTHENTICATED: "NOT_AUTHENTICATED";
        readonly SESSION_EXPIRED: "SESSION_EXPIRED";
        readonly PLAYER_NOT_FOUND: "PLAYER_NOT_FOUND";
        readonly RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED";
        readonly DUPLICATE_TRANSACTION: "DUPLICATE_TRANSACTION";
        readonly VALIDATION_FAILED: "VALIDATION_FAILED";
        readonly INVALID_PRODUCT: "INVALID_PRODUCT";
        readonly PURCHASE_FAILED: "PURCHASE_FAILED";
        readonly CONNECTION_ERROR: "CONNECTION_ERROR";
        readonly WEBSOCKET_ERROR: "WEBSOCKET_ERROR";
        readonly DATABASE_ERROR: "DATABASE_ERROR";
    };
    formatErrorForClient: typeof formatErrorForClient;
    formatUnknownErrorForClient: typeof formatUnknownErrorForClient;
    logError: typeof logError;
    sendErrorToClient: typeof sendErrorToClient;
    handleErrors: typeof handleErrors;
    handleErrorsSync: typeof handleErrorsSync;
    isGameError: typeof isGameError;
    isInsufficientResourcesError: typeof isInsufficientResourcesError;
    isServerError: typeof isServerError;
    isRateLimitError: typeof isRateLimitError;
    createErrorResponse: typeof createErrorResponse;
};
//# sourceMappingURL=error_handler.d.ts.map