TSK-1152: removed stacktrace from log for InvalidArgumentException.
This commit is contained in:
parent
ad31328e1b
commit
545c706547
|
|
@ -44,7 +44,7 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
||||||
@ExceptionHandler(InvalidArgumentException.class)
|
@ExceptionHandler(InvalidArgumentException.class)
|
||||||
protected ResponseEntity<Object> handleInvalidArgument(
|
protected ResponseEntity<Object> handleInvalidArgument(
|
||||||
InvalidArgumentException ex, WebRequest req) {
|
InvalidArgumentException ex, WebRequest req) {
|
||||||
return buildResponse(ex, req, HttpStatus.BAD_REQUEST);
|
return buildResponse(ex, req, HttpStatus.BAD_REQUEST, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(NotAuthorizedException.class)
|
@ExceptionHandler(NotAuthorizedException.class)
|
||||||
|
|
@ -150,13 +150,17 @@ public class TaskanaRestExceptionHandler extends ResponseEntityExceptionHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResponseEntity<Object> buildResponse(Exception ex, WebRequest req, HttpStatus status) {
|
private ResponseEntity<Object> buildResponse(Exception ex, WebRequest req, HttpStatus status) {
|
||||||
TaskanaErrorData errorData = new TaskanaErrorData(status, ex, req);
|
return buildResponse(ex, req, status, true);
|
||||||
logError(ex, errorData);
|
|
||||||
return ResponseEntity.status(status).body(errorData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logError(Exception ex, TaskanaErrorData errorData) {
|
private ResponseEntity<Object> buildResponse(
|
||||||
LOGGER.error(
|
Exception ex, WebRequest req, HttpStatus status, boolean logExceptionOnError) {
|
||||||
"Error occurred during processing of rest request:\n {}" + errorData.toString(), ex);
|
TaskanaErrorData errorData = new TaskanaErrorData(status, ex, req);
|
||||||
|
if (logExceptionOnError) {
|
||||||
|
LOGGER.error("Error occurred during processing of rest request: " + errorData.toString(), ex);
|
||||||
|
} else {
|
||||||
|
LOGGER.debug("Error occurred during processing of rest request: " + errorData.toString(), ex);
|
||||||
|
}
|
||||||
|
return ResponseEntity.status(status).body(errorData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue