All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.exception.ApplicationException Maven / Gradle / Ivy

package org.springframework.exception;

/**
 * @see org.springframework.http.HttpStatus
 */
public class ApplicationException extends AbstractException {
  private static final long serialVersionUID = -4542260304513400576L;

  public static final int DEFAULT_STATUS = 500;

  public static final String DEFAULT_CODE = "error";

  private final String code;

  private final int status;

  private final Object[] args;

  public ApplicationException(String message) {
    this(message, DEFAULT_CODE, DEFAULT_STATUS);
  }

  public ApplicationException(String message, String code) {
    this(message, code, DEFAULT_STATUS);
  }

  public ApplicationException(String code, int status) {
    this((String) null, code, status);
  }

  public ApplicationException(String code, int status, Object... args) {
    this((String) null, code, status);
  }

  public ApplicationException(String message, String code, int status, Object... args) {
    super(message);
    this.code = code;
    this.status = status;
    this.args = args;
  }

  public ApplicationException(String message, Throwable cause) {
    this(message, cause, DEFAULT_CODE, DEFAULT_STATUS);
  }

  public ApplicationException(String message, Throwable cause, String code) {
    this(message, cause, code, DEFAULT_STATUS);
  }

  public ApplicationException(Throwable cause, String code, int status, Object... args) {
    this((String) null, cause, code, status);
  }

  public ApplicationException(String message, Throwable cause, String code, int status, Object... args) {
    super(message, cause);
    this.code = code;
    this.status = status;
    this.args = args;
  }

  @Override
  public String getCode() {
    return this.code;
  }

  @Override
  public int getStatus() {
    return this.status;
  }

  @Override
  public Object[] getArgs() {
    return this.args;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy