package com.flightticket.exception;

import lombok.Getter;

/**
 * Exception thrown when Amadeus API returns an error during modification
 * Requirements: 7.4, 10.6
 */
@Getter
public class AmadeusApiException extends RuntimeException {
    
    private final ApiErrorType errorType;
    private final String apiErrorCode;
    private final Object apiErrorDetails;
    
    public enum ApiErrorType {
        VALIDATION_ERROR,
        BUSINESS_RULE_ERROR,
        TIMEOUT,
        SERVICE_UNAVAILABLE,
        AUTHENTICATION_ERROR,
        AUTHORIZATION_ERROR,
        RATE_LIMIT_EXCEEDED,
        UNKNOWN
    }
    
    public AmadeusApiException(String message, ApiErrorType errorType) {
        super(message);
        this.errorType = errorType;
        this.apiErrorCode = null;
        this.apiErrorDetails = null;
    }
    
    public AmadeusApiException(String message, Throwable cause, ApiErrorType errorType) {
        super(message, cause);
        this.errorType = errorType;
        this.apiErrorCode = null;
        this.apiErrorDetails = null;
    }
    
    public AmadeusApiException(String message, ApiErrorType errorType, String apiErrorCode) {
        super(message);
        this.errorType = errorType;
        this.apiErrorCode = apiErrorCode;
        this.apiErrorDetails = null;
    }
    
    public AmadeusApiException(String message, ApiErrorType errorType, String apiErrorCode, Object apiErrorDetails) {
        super(message);
        this.errorType = errorType;
        this.apiErrorCode = apiErrorCode;
        this.apiErrorDetails = apiErrorDetails;
    }
}
