@@ -159,7 +159,7 @@ public RestErrors handleAuthorizationDeniedException(@NotNull final Authorizatio
159159 @ ExceptionHandler (ValidationException .class )
160160 @ ResponseBody
161161 public ResponseEntity <RestErrors > handleValidationErrors (@ NotNull final ValidationException ex ) {
162- logger .debug (ex .getMessage (), ex );
162+ logger .debug ("Validation error: {}" , ex .getMessage ());
163163 RestErrors error = new RestErrors (ex .getErrors (), messageSource );
164164 return ResponseEntity .status (HttpStatus .BAD_REQUEST ).body (error );
165165 }
@@ -220,8 +220,13 @@ private boolean isExpectedException(Throwable ex) {
220220 public RestErrors handleSecurityErrors (@ NotNull UndeclaredThrowableException ex ) {
221221 final Throwable expected = getExpectedException (ex .getCause ());
222222 if (expected != null ) {
223- logger .debug ("Expected nested exception handled: {}" , expected .getMessage ());
223+ if (!(expected instanceof LockException )) {
224+ logger .debug ("Expected nested exception handled: {}" , expected .getMessage ());
225+ }
224226 if (expected instanceof ClientException ) {
227+ if (expected instanceof LockException ) {
228+ return handleLockException ((LockException ) expected );
229+ }
225230 return handleClientErrors ((ClientException ) expected );
226231 } else if (expected instanceof ValidationException ) {
227232 return new RestErrors (((ValidationException ) expected ).getErrors (), messageSource );
@@ -341,6 +346,15 @@ public RestErrors handleWrongAuthenticationTypeException(@NotNull WrongAuthentic
341346 return new RestErrors (message , Severity .WARNING );
342347 }
343348
349+ @ ExceptionHandler (LockException .class )
350+ @ ResponseStatus (HttpStatus .BAD_REQUEST )
351+ @ ResponseBody
352+ public RestErrors handleLockException (@ NotNull LockException ex ) {
353+ logger .warn (ex .getMessage ());
354+ final Locale locale = LocaleContextHolder .getLocale ();
355+ return new RestErrors (ex .getMessage (messageSource , locale ), ex .getSeverity (), ex .getTechInfo ());
356+ }
357+
344358 @ ExceptionHandler (ClientException .class )
345359 @ ResponseStatus (HttpStatus .BAD_REQUEST )
346360 @ ResponseBody
0 commit comments