package cloud.nstart.terravault.ordinis.restapi.error;

import org.springframework.http.HttpStatus;

public class OrdinisException extends RuntimeException {

  private final HttpStatus status;
  private final String code;

  public OrdinisException(HttpStatus status, String code, String message) {
    super(message);
    this.status = status;
    this.code = code;
  }

  public HttpStatus getStatus() { return status; }
  public String getCode() { return code; }

  public static OrdinisException notFound(String code, String message) {
    return new OrdinisException(HttpStatus.NOT_FOUND, code, message);
  }

  public static OrdinisException conflict(String code, String message) {
    return new OrdinisException(HttpStatus.CONFLICT, code, message);
  }

  public static OrdinisException badRequest(String code, String message) {
    return new OrdinisException(HttpStatus.BAD_REQUEST, code, message);
  }

  public static OrdinisException forbidden(String code, String message) {
    return new OrdinisException(HttpStatus.FORBIDDEN, code, message);
  }

  public static OrdinisException unprocessableEntity(String code, String message) {
    return new OrdinisException(HttpStatus.UNPROCESSABLE_ENTITY, code, message);
  }
}
