Skip to content

Commit

Permalink
Makes ErrorHandling not optional in ListenerConfig by specifying a cr…
Browse files Browse the repository at this point in the history
…eate method.
  • Loading branch information
spericas committed Feb 24, 2025
1 parent 4a6e302 commit 5e71e9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,23 +312,16 @@ public void run() {
// gather error handling properties
ErrorHandling errorHandling = ctx.listenerContext()
.config()
.errorHandling()
.orElse(null);
boolean includeEntity = false;
boolean logAllMessages = false;
if (errorHandling != null) {
includeEntity = errorHandling.includeEntity();
logAllMessages = errorHandling.logAllMessages();
}
.errorHandling();

// log message in DEBUG mode
if (LOGGER.isLoggable(DEBUG) && (e.safeMessage() || logAllMessages)) {
if (LOGGER.isLoggable(DEBUG) && (e.safeMessage() || errorHandling.logAllMessages())) {
LOGGER.log(DEBUG, e);
}

// create message to return based on settings
String message = null;
if (includeEntity) {
if (errorHandling.includeEntity()) {
message = e.safeMessage() ? e.getMessage() : "Bad request, see server log for more information";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ default void configureSocket(ServerSocket socket) {
/**
* Configuration for this listener's error handling.
*
* @return optional error handling
* @return error handling
*/
@Option.Configured
Optional<ErrorHandling> errorHandling();
@Option.DefaultMethod("create")
ErrorHandling errorHandling();
}
Original file line number Diff line number Diff line change
Expand Up @@ -648,23 +648,16 @@ private void handleRequestException(RequestException e) {
// gather error handling properties
ErrorHandling errorHandling = ctx.listenerContext()
.config()
.errorHandling()
.orElse(null);
boolean includeEntity = false;
boolean logAllMessages = false;
if (errorHandling != null) {
includeEntity = errorHandling.includeEntity();
logAllMessages = errorHandling.logAllMessages();
}
.errorHandling();

// log message in DEBUG mode
if (LOGGER.isLoggable(DEBUG) && (e.safeMessage() || logAllMessages)) {
if (LOGGER.isLoggable(DEBUG) && (e.safeMessage() || errorHandling.logAllMessages())) {
LOGGER.log(DEBUG, e);
}

// create message to return based on settings
String message = null;
if (includeEntity) {
if (errorHandling.includeEntity()) {
message = e.safeMessage() ? e.getMessage() : "Bad request, see server log for more information";
}

Expand Down

0 comments on commit 5e71e9f

Please sign in to comment.