Legger til en klasse som representerer en nettverksfeilmelding

This commit is contained in:
Kristian Knarvik 2020-03-19 11:46:55 +01:00
parent e559048f07
commit 2835a253fa

View File

@ -0,0 +1,43 @@
package inf112.fiasko.roborally.networking;
/**
* This class represents a response saying that something went wrong with the request
*/
public class ErrorResponse {
private String errorMessage;
private Exception thrownException;
/**
* Constructs a new error response
* @param errorMessage The error message describing the error
*/
public ErrorResponse(String errorMessage) {
this.errorMessage = errorMessage;
}
/**
* Constructs a new error response
* @param errorMessage The error message describing the error
* @param thrownException The exception to throw
*/
public ErrorResponse(String errorMessage, Exception thrownException) {
this.errorMessage = errorMessage;
this.thrownException = thrownException;
}
/**
* Gets the error message attached to the error response
* @return An error message
*/
public String getErrorMessage() {
return this.errorMessage;
}
/**
* Gets the exception attached to the error response
* @return An exception or null
*/
public Exception getThrownException() {
return this.thrownException;
}
}