File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
src/main/java/lk/ijse/dep/note/advice Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ package lk .ijse .dep .note .advice ;
2+
3+ import lk .ijse .dep .note .service .exception .DuplicateEmailException ;
4+ import lk .ijse .dep .note .service .exception .NotFoundException ;
5+ import org .springframework .http .HttpStatus ;
6+ import org .springframework .web .bind .annotation .ExceptionHandler ;
7+ import org .springframework .web .bind .annotation .ResponseStatus ;
8+ import org .springframework .web .bind .annotation .RestControllerAdvice ;
9+ import org .springframework .web .server .ResponseStatusException ;
10+
11+ @ RestControllerAdvice
12+ public class GlobalExceptionHandler {
13+
14+ @ ExceptionHandler (DuplicateEmailException .class )
15+ public void handleDuplicateEmailexception (DuplicateEmailException e ){
16+ e .initCause ( new ResponseStatusException (HttpStatus .CONFLICT ,e .getMessage ()));
17+ }
18+ @ ExceptionHandler (NotFoundException .class )
19+ public void handleNotfoundExcpetion (NotFoundException e ){
20+ e .initCause (new ResponseStatusException (HttpStatus .NOT_FOUND ,e .getMessage ()));
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments