|
2 | 2 |
|
3 | 3 | import com.hms.management.rest.Exceptions.InvalidNameException; |
4 | 4 | import com.hms.management.rest.Exceptions.InvalidPasswordException; |
5 | | -import org.aspectj.lang.annotation.Before; |
6 | 5 | import org.springframework.http.HttpStatus; |
7 | | -import org.springframework.http.ResponseEntity; |
8 | 6 | import org.springframework.web.bind.annotation.ControllerAdvice; |
9 | 7 | import org.springframework.web.bind.annotation.ExceptionHandler; |
10 | 8 | import org.springframework.web.bind.annotation.ResponseBody; |
|
14 | 12 |
|
15 | 13 | @ControllerAdvice |
16 | 14 | public class UserManagementRestControllerExceptionHandler { |
| 15 | + |
17 | 16 | @ResponseBody |
18 | 17 | @ExceptionHandler(value = InvalidNameException.class) |
19 | | - public Map<String,String> invalidUserNameException(){ |
20 | | - Map<String,String> map = new HashMap<String, String>() ; |
21 | | - map.put("status",HttpStatus.NOT_FOUND.toString()); |
22 | | - map.put("error","invalid user name. please enter a valid user name"); |
| 18 | + public Map<String, String> invalidUserNameException() { |
| 19 | + Map<String, String> map = new HashMap<String, String>(); |
| 20 | + map.put("status", HttpStatus.NOT_FOUND.toString()); |
| 21 | + map.put("error", "invalid user name. please enter a valid user name"); |
23 | 22 |
|
24 | | - return map; |
| 23 | + return map; |
25 | 24 |
|
26 | 25 | } |
27 | 26 |
|
28 | 27 | @ResponseBody |
29 | 28 | @ExceptionHandler(value = InvalidPasswordException.class) |
30 | | - public Map<String,String> invalidUserPasswordException(){ |
31 | | - Map<String,String> map = new HashMap<String, String>() ; |
32 | | - map.put("status",HttpStatus.NOT_FOUND.toString()); |
33 | | - map.put("error","invalid password. please enter a valid password less than 20 characters"); |
| 29 | + public Map<String, String> invalidUserPasswordException() { |
| 30 | + Map<String, String> map = new HashMap<String, String>(); |
| 31 | + map.put("status", HttpStatus.NOT_FOUND.toString()); |
| 32 | + map.put("error", "invalid password. please enter a valid password less than 20 characters"); |
34 | 33 |
|
35 | 34 | return map; |
36 | 35 |
|
|
0 commit comments