/**
 * Error handling utilities for TypeScript strict mode compatibility
 */

/**
 * Safely extract error message from unknown error type
 */
export function getErrorMessage(error: unknown): string {
  if (error instanceof Error) {
    return error.message;
  }
  return String(error);
}

/**
 * Safely extract error stack from unknown error type
 */
export function getErrorStack(error: unknown): string | undefined {
  if (error instanceof Error) {
    return error.stack;
  }
  return undefined;
}

/**
 * Safely extract error name from unknown error type
 */
export function getErrorName(error: unknown): string {
  if (error instanceof Error) {
    return error.name;
  }
  return 'Error';
}

/**
 * Check if error is a specific error type by name
 */
export function isErrorType(error: unknown, name: string): boolean {
  if (error instanceof Error) {
    return error.name === name;
  }
  return false;
}
