Skip to content
Snippets Groups Projects

feat: Add generic ApplicationException

2 unresolved threads
Files
4
/*********************************************************************
* Copyright (c) 2023 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.core.exception;
/**
* A custom exception used as a wrapper to handle basic runtime exceptions.
*/
public class ApplicationException extends RuntimeException {
private final Integer statusCode;
/**
* Instantiate an ApplicationException with a message. 500 Status is assumed.
*
* @param message the message to display
*/
public ApplicationException(String message) {
Please register or sign in to reply
this(message, 500);
}
/**
* Instantiate an ApplicationException with a message and http response status
* code.
*
* @param message the message to display
* @param statusCode The status code to return to the client
*/
public ApplicationException(String message, Integer statusCode) {
super(message);
this.statusCode = statusCode;
}
/**
* Instantiate an ApplicationException with a message and a cause. Status 500 is
* assumed.
*
* @param message the message to display
* @param cause The cause of the error
*/
public ApplicationException(String message, Throwable cause) {
this(message, cause, 500);
}
/**
* Instantiate an ApplicationException with a message, http response code, and a
* cause;
*
* @param message the message to display
* @param cause The cause of the error
* @param statusCode The status code to return to the client
*/
public ApplicationException(String message, Throwable cause, Integer statusCode) {
super(message, cause);
this.statusCode = statusCode;
}
/**
* Retrieve the current status code.
*
* @return The exception status code.
*/
public Integer getStatusCode() {
return this.statusCode;
}
}
Loading