Skip to content

Commit 9401c54

Browse files
committed
refactor LitterStatus regarding consultation with Vasile, adding extra error code and Exception Handling by Kevin's user service
1 parent d918ded commit 9401c54

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/main/java/com/csaba79coder/littersnap/exception/ControllerExceptionHandler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import static com.csaba79coder.littersnap.value.ErrorCode.LS_001;
1616
import static com.csaba79coder.littersnap.value.ErrorCode.LS_002;
1717
import static com.csaba79coder.littersnap.value.ErrorCode.LS_003;
18+
import static com.csaba79coder.littersnap.value.ErrorCode.LS_004;
19+
import static com.csaba79coder.littersnap.value.ErrorCode.LS_005;
1820

1921
@ControllerAdvice
2022
public class ControllerExceptionHandler {
@@ -36,7 +38,12 @@ public ResponseEntity<Object> handleInvalidPasswordOrUsernameException(Validatio
3638

3739
@ExceptionHandler(value = {SendFailedException.class})
3840
public ResponseEntity<Object> handleSendFailedException(SendFailedException ex) {
39-
return new ResponseEntity<>(responseBodyWithMessage(LS_003, ex.getMessage()), HttpStatus.BAD_REQUEST);
41+
return new ResponseEntity<>(responseBodyWithMessage(LS_004, ex.getMessage()), HttpStatus.BAD_REQUEST);
42+
}
43+
44+
@ExceptionHandler(value = {IllegalArgumentException.class})
45+
public ResponseEntity<Object> handleIllegalArgumentException(IllegalArgumentException ex) {
46+
return new ResponseEntity<>(responseBodyWithMessage(LS_005, ex.getMessage()), HttpStatus.INTERNAL_SERVER_ERROR);
4047
}
4148

4249
private String responseBodyWithMessage(ErrorCode code, String message) {

src/main/java/com/csaba79coder/littersnap/value/ErrorCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
public enum ErrorCode {
44

5-
LS_001, LS_002, LS_003, LS_004
5+
LS_001, LS_002, LS_003, LS_004, LS_005
66
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.csaba79coder.littersnap.value;
22

33
public enum LitterStatus {
4-
5-
COLLECTED,
6-
REMOVED,
74
REPORTED,
8-
UNREPORTED,
5+
COMPLETED,
6+
PROCESSING,
97
NOT_FOUND
108
}

0 commit comments

Comments
 (0)