package com.banesco.common.domain.exception;

import com.banesco.common.domain.model.ApiResponse;
import lombok.Getter;

@Getter
public class HttpApiResponseException extends RuntimeException {
    private final int statusCode;
    private final transient ApiResponse<?> apiResponse;

    public HttpApiResponseException(int statusCode, ApiResponse<?> apiResponse) {
        super(String.format(
            "HTTP %d: %s", statusCode,
            apiResponse.getStatusResponse() != null ?
            apiResponse.getStatusResponse().getMessage() : "Error sin mensaje"
        ));
        this.statusCode = statusCode;
        this.apiResponse = apiResponse;
    }
}