Skip to content

Commit c11920a

Browse files
committed
minor fixes.
1 parent bdf919e commit c11920a

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

BankApplicationBackend/src/main/java/com/demo/bankapp/exception/configuration/RestExceptionHandler.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected ResponseEntity<Object> handleMethodArgumentNotValid(final MethodArgume
4040
final WebRequest request) {
4141
logger.info(ex.getClass().getName());
4242
//
43-
final List<String> errors = new ArrayList<String>();
43+
final List<String> errors = new ArrayList<>();
4444
for (final FieldError error : ex.getBindingResult().getFieldErrors()) {
4545
errors.add(error.getField() + ": " + error.getDefaultMessage());
4646
}
@@ -55,7 +55,7 @@ protected ResponseEntity<Object> handleMethodArgumentNotValid(final MethodArgume
5555
protected ResponseEntity<Object> handleBindException(final BindException ex, final HttpHeaders headers, final HttpStatus status, final WebRequest request) {
5656
logger.info(ex.getClass().getName());
5757
//
58-
final List<String> errors = new ArrayList<String>();
58+
final List<String> errors = new ArrayList<>();
5959
for (final FieldError error : ex.getBindingResult().getFieldErrors()) {
6060
errors.add(error.getField() + ": " + error.getDefaultMessage());
6161
}
@@ -122,17 +122,6 @@ protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(final HttpMedia
122122
final ApiError apiError = new ApiError(HttpStatus.UNSUPPORTED_MEDIA_TYPE, ex.getLocalizedMessage(), builder.substring(0, builder.length() - 2));
123123
return buildResponseEntity(ex, apiError);
124124
}
125-
126-
// 500
127-
128-
// @ExceptionHandler({ Exception.class })
129-
// public ResponseEntity<Object> handleAll(final Exception ex, final WebRequest request) {
130-
// logger.info(ex.getClass().getName());
131-
// logger.error("error", ex);
132-
// //
133-
// final ApiError apiError = new ApiError(HttpStatus.INTERNAL_SERVER_ERROR, ex.getLocalizedMessage(), "error occurred");
134-
// return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
135-
// }
136125

137126
@ExceptionHandler({ MethodArgumentTypeMismatchException.class })
138127
public ResponseEntity<Object> handleMethodArgumentTypeMismatch(final MethodArgumentTypeMismatchException ex, final WebRequest request) {
@@ -143,7 +132,7 @@ public ResponseEntity<Object> handleMethodArgumentTypeMismatch(final MethodArgum
143132

144133
@ExceptionHandler({ ConstraintViolationException.class })
145134
public ResponseEntity<Object> handleConstraintViolation(final ConstraintViolationException ex, final WebRequest request) {
146-
final List<String> errors = new ArrayList<String>();
135+
final List<String> errors = new ArrayList<>();
147136
for (final ConstraintViolation<?> violation : ex.getConstraintViolations()) {
148137
errors.add(violation.getRootBeanClass().getName() + " " + violation.getPropertyPath() + ": " + violation.getMessage());
149138
}
@@ -194,7 +183,7 @@ private ResponseEntity<Object> buildResponseEntity(Exception ex, ApiError apiErr
194183
logger.info(ex.getClass().getName());
195184
logger.error("error", ex);
196185

197-
return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
186+
return new ResponseEntity<>(apiError, new HttpHeaders(), apiError.getStatus());
198187
}
199188

200189
}

0 commit comments

Comments
 (0)