diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/push/UpdateErrorHandler.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/push/UpdateErrorHandler.java index c453c9bc..35790109 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/push/UpdateErrorHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/push/UpdateErrorHandler.java @@ -56,14 +56,14 @@ public final class UpdateErrorHandler implements Function { } catch (final Exception ee) { log.warn("Unable to auto-logout: ", ee.getMessage()); } - return true; + return false; } } @Override public Boolean apply(final Exception error) { this.errors++; - log.error("Failed to update server push: {}", error.getMessage(), error); + log.warn("Failed to update server push: {}", error.getMessage()); if (this.errors > 5) { checkUserSession(); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java index d49e8c4d..d8d89ff9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/ExamSessionServiceImpl.java @@ -241,7 +241,9 @@ public class ExamSessionServiceImpl implements ExamSessionService { flushCache(exam); } - log.info("Exam {} is not currently running", examId); + if (log.isDebugEnabled()) { + log.info("Exam {} is not currently running", examId); + } return Result.ofError(new NoSuchElementException( "No currently running exam found for id: " + examId)); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java index ab726f6c..d5a80ccd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientConnectionServiceImpl.java @@ -329,7 +329,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic if (StringUtils.isNoneBlank(clientAddress) && StringUtils.isNotBlank(clientConnection.clientAddress) && !clientAddress.equals(clientConnection.clientAddress)) { - log.error( + log.warn( "ClientConnection integrity violation: client address mismatch: {}, {}", clientAddress, clientConnection.clientAddress); @@ -337,7 +337,7 @@ public class SEBClientConnectionServiceImpl implements SEBClientConnectionServic "ClientConnection integrity violation: client address mismatch"); } } else if (!clientConnection.status.clientActiveStatus) { - log.error("ClientConnection integrity violation: client connection is not in expected state: {}", + log.warn("ClientConnection integrity violation: client connection is not in expected state: {}", clientConnection); throw new IllegalArgumentException( "ClientConnection integrity violation: client connection is not in expected state"); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java index 89a1c31f..6c2decb6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/SEBClientNotificationServiceImpl.java @@ -93,7 +93,7 @@ public class SEBClientNotificationServiceImpl implements SEBClientNotificationSe this.clientEventDAO.getPendingNotificationByValue(clientConnection.id, notificationId) .flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notification.id)) .map(this::removeFromCache) - .onError(error -> log.error("Failed to confirm pending notification: {}", event, error)); + .getOrThrow(); } catch (final Exception e) { log.error( @@ -110,8 +110,7 @@ public class SEBClientNotificationServiceImpl implements SEBClientNotificationSe return this.clientEventDAO.getPendingNotification(notificationId) .map(notification -> this.confirmClientSide(notification, examId, connectionToken)) .flatMap(notification -> this.clientEventDAO.confirmPendingNotification(notificationId)) - .map(this::removeFromCache) - .onError(error -> log.error("Failed to confirm pending notification: {}", notificationId, error)); + .map(this::removeFromCache); } @Override diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java index 4d0581d2..d8f02488 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java @@ -149,6 +149,15 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler { HttpStatus.BAD_REQUEST); } + @ExceptionHandler(IllegalArgumentException.class) + public ResponseEntity handleIllegalArgumentException( + final IllegalArgumentException ex, + final WebRequest request) { + + log.warn("Illegal argument or state detected: {}\n send 400 Bad Request response", ex.getMessage()); + return new ResponseEntity<>(HttpStatus.BAD_REQUEST); + } + @ExceptionHandler(ResourceNotFoundException.class) public ResponseEntity handleResourceNotFoundException( final ResourceNotFoundException ex, @@ -182,7 +191,7 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler { final ExamNotRunningException ex, final WebRequest request) { - log.info("{}", ex.getMessage()); + log.debug("{}", ex.getMessage()); return APIMessage.ErrorMessage.INTEGRITY_VALIDATION .createErrorResponse(ex.getMessage()); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamMonitoringController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamMonitoringController.java index 81c790e9..36aec030 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamMonitoringController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamMonitoringController.java @@ -425,7 +425,10 @@ public class ExamMonitoringController { notificationId, examId, connectionToken) - .getOrThrow(); + .onError(error -> { + log.error("Failed to confirm pending notification: {} for exam {}, cause: {}", + notificationId, examId, error.getMessage()); + }); } @RequestMapping( diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java index e8d72124..6d62f73d 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/UseCasesIntegrationTest.java @@ -1578,7 +1578,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { fail("Exception expected here"); } catch (final Exception e) { - assertEquals("Unexpected error while rest call", e.getMessage()); + assertEquals("argument \"content\" is null", e.getMessage()); } // test follow-up integrity violation @@ -1596,7 +1596,7 @@ public class UseCasesIntegrationTest extends GuiIntegrationTest { fail("Exception expected here"); } catch (final Exception e) { - assertEquals("Unexpected error while rest call", e.getMessage()); + assertEquals("argument \"content\" is null", e.getMessage()); } final ConfigurationTableValues newTableValue = new ConfigurationTableValues(