StackAsk is a community where developers ask questions, share answers and learn from each others real-world experience, so every solved problem helps the next person who runs into it.
field:invalid
Map<String, String> errors = new HashMap<>()<span>;</span> Throwable <span>cause</span> = e.getCause()<span>;</span> if (<span>cause</span> <span>instanceof </span>InvalidFormatException) { InvalidFormatException ex = (InvalidFormatException) <span>cause</span><span>;</span> for (<span>JsonMappingException.Reference </span>ref : ex.getPath()) { errors.put(ref.getFieldName(), <span>"invalid"</span>)<span>;</span> } } else { errors.put(<span>"fields"</span>, <span>"invalid"</span>)<span>;</span> } return ResponseEntity.<span>badRequest( </span> errors )<span>;</span>
GlobalExceptionHandler
@ControllerAdvice
InvalidFormatException
2.2K Point(s)
1.2K Point(s)
313 Point(s)
178 Point(s)
138 Point(s)
Input your email to receive reset password link, or if you remember your password, you can click