diff --git a/src/main/kotlin/com/example/demo/exceptions/GlobalExceptionHandler.kt b/src/main/kotlin/com/example/demo/exceptions/GlobalExceptionHandler.kt index 02c0fb2..a3d86b8 100644 --- a/src/main/kotlin/com/example/demo/exceptions/GlobalExceptionHandler.kt +++ b/src/main/kotlin/com/example/demo/exceptions/GlobalExceptionHandler.kt @@ -16,13 +16,11 @@ import java.util.stream.Collectors class GlobalExceptionHandler : ResponseEntityExceptionHandler() { override fun handleMethodArgumentNotValid(ex: MethodArgumentNotValidException, headers: HttpHeaders, status: HttpStatusCode, request: WebRequest): ResponseEntity? { - val body: MutableMap> = HashMap() + val body: MutableMap> = HashMap() val errors = ex.bindingResult .fieldErrors - .stream() - .map { obj: FieldError -> obj.defaultMessage } - .collect(Collectors.toList()) + .associate { obj: FieldError -> obj.field to obj.defaultMessage } body["errors"] = errors