/**
 * Presentation Error Type
 * 
 * Errors that can be handled by the presentation layer (RSC pages, templates).
 * These are mapped from DomainErrors by PageQueries.
 */

export type PresentationError = 
  | 'notFound'           // Resource not found - show 404 page
  | 'redirect'           // Redirect to another page (e.g., login)
  | 'unauthorized'       // Not authorized - show access denied
  | 'serverError'        // Generic server error
  | 'networkError'       // Network/communication error
  | 'validationError'    // Invalid input data
  | 'unknown';           // Unknown error

// Helper to map DomainError to PresentationError
export function mapToPresentationError(domainError: any): PresentationError {
  const errorType = domainError?.type || domainError?.name || 'unknown';
  
  switch (errorType) {
    case 'notFound':
    case 'NotFoundError':
      return 'notFound';
    case 'unauthorized':
    case 'UnauthorizedError':
    case 'ForbiddenError':
      return 'unauthorized';
    case 'serverError':
    case 'ServerError':
    case 'HttpServerError':
      return 'serverError';
    case 'networkError':
    case 'NetworkError':
      return 'networkError';
    case 'validationError':
    case 'ValidationError':
      return 'validationError';
    default:
      return 'unknown';
  }
}
