#76 Set a message for error responses

Without one, clients might treat errors as generic failures instead of
handling them in a manner appropriate for their error code
This commit is contained in:
Xavier Johnson
2020-12-18 22:52:45 -05:00
parent 90b2b5301c
commit e7c4c12a98
3 changed files with 3 additions and 1 deletions

View File

@@ -23,5 +23,6 @@ package io.kamax.mxisd.exception;
public class InvalidParamException extends RuntimeException { public class InvalidParamException extends RuntimeException {
public InvalidParamException() { public InvalidParamException() {
super("The chosen hash algorithm is invalid or disallowed");
} }
} }

View File

@@ -23,5 +23,6 @@ package io.kamax.mxisd.exception;
public class InvalidPepperException extends RuntimeException { public class InvalidPepperException extends RuntimeException {
public InvalidPepperException() { public InvalidPepperException() {
super("The provided pepper is invalid or expired");
} }
} }

View File

@@ -189,7 +189,7 @@ public abstract class BasicHttpHandler implements HttpHandler {
} }
protected void respond(HttpServerExchange ex, int status, String errCode, String error) { protected void respond(HttpServerExchange ex, int status, String errCode, String error) {
respond(ex, status, buildErrorBody(ex, errCode, error)); respond(ex, status, buildErrorBody(ex, errCode, error != null ? error : "An error has occurred"));
} }
protected void handleException(HttpServerExchange exchange, HttpMatrixException ex) { protected void handleException(HttpServerExchange exchange, HttpMatrixException ex) {