• Creates a standardized application error object with optional recovery hints. Constructs an AppError with type, message, original error reference, and optional code.

    Parameters

    • type: ErrorType

      The error type.

    • message: string

      The error message.

    • OptionaloriginalError: unknown

      The original error object, if any.

    • Optionalcode: string

      Optional error code for categorization.

    • OptionalrecoveryAction: ErrorRecoveryAction

      Optional recovery action hint for the UI.

    • OptionalrecoveryMessage: string

      Optional user-friendly recovery instruction.

    Returns AppError

    The constructed AppError object.

    export function createError(
    type: ErrorType,
    message: string,
    originalError?: unknown,
    code?: string,
    recoveryAction?: ErrorRecoveryAction,
    recoveryMessage?: string,
    ): AppError {
    console.error(message);
    console.debug(
    "[ErrorHandling] 🔍 Creating error: " +
    type +
    " - " +
    message +
    (code ? " (" + code + ")" : ""),
    );

    return {
    type,
    message,
    originalError,
    code,
    recoveryAction,
    recoveryMessage,
    };
    }