package com.kamco.cd.training.common.exception;

import com.kamco.cd.training.common.utils.ErrorCode;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
public class CustomApiException extends RuntimeException {

  private final String codeName; // ApiResponseCode enum name과 맞추는 용도 (예: "UNPROCESSABLE_ENTITY")
  private final HttpStatus status; // 응답으로 내려줄 HttpStatus

  public CustomApiException(String codeName, HttpStatus status, String message) {
    super(message);
    this.codeName = codeName;
    this.status = status;
  }

  public CustomApiException(String codeName, HttpStatus status) {
    this.codeName = codeName;
    this.status = status;
  }

  public CustomApiException(ErrorCode errorCode) {
    this.codeName = errorCode.getCode();
    this.status = errorCode.getStatus();
  }
}
