From 2835a253fa76943858a017eac86d9ad39f6d487a Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 19 Mar 2020 11:46:55 +0100 Subject: [PATCH] Legger til en klasse som representerer en nettverksfeilmelding --- .../roborally/networking/ErrorResponse.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/inf112/fiasko/roborally/networking/ErrorResponse.java diff --git a/src/main/java/inf112/fiasko/roborally/networking/ErrorResponse.java b/src/main/java/inf112/fiasko/roborally/networking/ErrorResponse.java new file mode 100644 index 0000000..2aff2f6 --- /dev/null +++ b/src/main/java/inf112/fiasko/roborally/networking/ErrorResponse.java @@ -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; + } +}