From 7d44f4740681076033ce74be43a136e9fd2a48b6 Mon Sep 17 00:00:00 2001 From: "Robert.McCormack" Date: Tue, 16 Jul 2024 14:32:18 +0100 Subject: [PATCH] DST-16017 : Change error message when getting NoSuchAttributeException --- .../ndelius/advice/ControllerExceptionHandler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/uk/co/bconline/ndelius/advice/ControllerExceptionHandler.java b/src/main/java/uk/co/bconline/ndelius/advice/ControllerExceptionHandler.java index 3c43caa6..3d263244 100644 --- a/src/main/java/uk/co/bconline/ndelius/advice/ControllerExceptionHandler.java +++ b/src/main/java/uk/co/bconline/ndelius/advice/ControllerExceptionHandler.java @@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; import lombok.val; import org.springframework.http.HttpStatus; +import org.springframework.ldap.NoSuchAttributeException; import org.springframework.security.access.AccessDeniedException; import org.springframework.stereotype.Component; import org.springframework.validation.ObjectError; @@ -107,6 +108,14 @@ public ErrorResponse handle(BulkheadFullException exception) { return new ErrorResponse("An export task is currently in progress. Please try again later."); } + @ExceptionHandler + @ResponseBody + @ResponseStatus(HttpStatus.CONFLICT) + public ErrorResponse handle(NoSuchAttributeException exception) { + log.error("Returning 409 response", exception); + return new ErrorResponse("User account is corrupted, please contact the help desk"); + } + private T getLast(Iterator propertyPath) { T node = null; while (propertyPath.hasNext()) node = propertyPath.next();