Skip to content

Commit aaff088

Browse files
author
muriloalvesdev
committed
handlerException for UserNotFoundException
1 parent c07bfc3 commit aaff088

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/main/java/br/com/developers/controller/handler/HandlerException.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import br.com.developers.exception.ExistingEmailException;
1111
import br.com.developers.exception.IllegalRoleException;
1212
import br.com.developers.exception.RoleNotFoundException;
13+
import br.com.developers.exception.UserNotFoundException;
1314

1415
@ControllerAdvice
1516
public class HandlerException extends ResponseEntityExceptionHandler {
@@ -41,6 +42,12 @@ public ResponseEntity<ApiException> handleRoleNotFoundException(RoleNotFoundExce
4142
.body(createResponse(ex.getMessage(), NOT_FOUND.value()));
4243
}
4344

45+
@ExceptionHandler(UserNotFoundException.class)
46+
public ResponseEntity<ApiException> handleUserNotFoundException(UserNotFoundException ex) {
47+
return ResponseEntity.status(NOT_FOUND)
48+
.body(createResponse(ex.getMessage(), NOT_FOUND.value()));
49+
}
50+
4451
private ApiException createResponse(String message, int httpValue) {
4552
return new ApiException(message, httpValue);
4653
}

0 commit comments

Comments
 (0)