Last change
on this file since 1ad8e64 was 1ad8e64, checked in by Ema <ema_spirova@…>, 3 years ago |
spring security
|
-
Property mode
set to
100644
|
File size:
829 bytes
|
Line | |
---|
1 | package finki.diplomska.tripplanner.models.exceptions;
|
---|
2 |
|
---|
3 | import org.springframework.http.HttpStatus;
|
---|
4 | import org.springframework.http.ResponseEntity;
|
---|
5 | import org.springframework.web.bind.annotation.ControllerAdvice;
|
---|
6 | import org.springframework.web.bind.annotation.ExceptionHandler;
|
---|
7 | import org.springframework.web.bind.annotation.RestController;
|
---|
8 | import org.springframework.web.context.request.WebRequest;
|
---|
9 |
|
---|
10 | @ControllerAdvice
|
---|
11 | @RestController
|
---|
12 | public class CustomResponseEntityExceptionHandler {
|
---|
13 | @ExceptionHandler
|
---|
14 | public final ResponseEntity<Object> handleUsernameAlreadyExists(UsernameAlreadyExistsException ex, WebRequest request){
|
---|
15 | UsernameAlreadyExistsResponse exceptionResponse = new UsernameAlreadyExistsResponse(ex.getMessage());
|
---|
16 | return new ResponseEntity(exceptionResponse, HttpStatus.BAD_REQUEST);
|
---|
17 | }
|
---|
18 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.