diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d8c4a89..01244f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,8 @@ stages: variables: MAVEN_OPTS: "-Dmaven.repo.local=.m2" +image: maven:3-jdk-11 + cache: paths: - .m2/ @@ -35,7 +37,6 @@ package: - target/* maven-repo: - image: maven:3-jdk-11 stage: build needs: [ package ] script: @@ -45,7 +46,6 @@ maven-repo: ossrh: stage: deploy - image: maven:3-jdk-11 only: - tags script: diff --git a/README.md b/README.md index ba58689..8eb4cad 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ported to all releases. ## Installation -Irked is available from the [Maven Central Repository](https://central.sonatype.com/artifact/tech.greenfield/irked-vertx/4.5.11.2). +Irked is available from the [Maven Central Repository](https://central.sonatype.com/artifact/tech.greenfield/irked-vertx/4.5.11.3). If using Maven, add Irked as a dependency in your `pom.xml` file: @@ -23,12 +23,12 @@ If using Maven, add Irked as a dependency in your `pom.xml` file: tech.greenfield irked-vertx - 4.5.11.2 + 4.5.11.3 ``` For other build tools, see the Maven Central website for the syntax, but it generally -boils down to just using `tech.greenfield:irked-vertx:4.5.11.2` as the dependency string. +boils down to just using `tech.greenfield:irked-vertx:4.5.11.3` as the dependency string. ## Quick Start diff --git a/pom.xml b/pom.xml index 5299351..f6b8184 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ tech.greenfield irked-vertx - 4.5.11.2 + 4.5.11.3 jar irked-vertx Opinionated framework for vertx-web route configuration and dispatch diff --git a/src/main/java/tech/greenfield/vertx/irked/helpers/JsonDecodingExceptionFormatter.java b/src/main/java/tech/greenfield/vertx/irked/helpers/JsonDecodingExceptionFormatter.java index d6c8d4b..b6ba675 100644 --- a/src/main/java/tech/greenfield/vertx/irked/helpers/JsonDecodingExceptionFormatter.java +++ b/src/main/java/tech/greenfield/vertx/irked/helpers/JsonDecodingExceptionFormatter.java @@ -2,10 +2,12 @@ import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; import com.fasterxml.jackson.core.JsonLocation; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonMappingException.Reference; +import com.fasterxml.jackson.databind.exc.InvalidFormatException; import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException; import io.vertx.core.json.DecodeException; @@ -16,11 +18,24 @@ public static String formatFriendlyErrorMessage(DecodeException e) { var cause = e.getCause(); if (cause instanceof UnrecognizedPropertyException) return formatUnrecognizedPropertyMessage((UnrecognizedPropertyException)cause); + if (cause instanceof InvalidFormatException) + return formatInvalidFormatMessage((InvalidFormatException)cause); if (cause instanceof JsonMappingException) return formatJsonMappingMessage((JsonMappingException)cause); return "Unexpected JSON decoding problem: " + e.getMessage(); } + public static String formatInvalidFormatMessage(InvalidFormatException e) { + var target = e.getTargetType(); + var field = e.getPath().stream().reduce((a,b) -> b).map(r -> r.getFieldName()).orElse("UNKNOWN"); + if (target.isEnum()) + return String.format("Value '%s' is not one of the supported values for '%s', out of: %s %s", e.getValue(), + field, Stream.of(target.getEnumConstants()).map(Object::toString).collect(Collectors.joining(", ")), + describeLocation(e.getPath(), e.getLocation())); + return String.format("Value '%s' is a valid value for '' %s", e.getValue(), field, + describeLocation(e.getPath(), e.getLocation())); + } + public static String formatJsonMappingMessage(JsonMappingException e) { return String.format("%s %s", e.getOriginalMessage(), describeLocation(e.getPath(), e.getLocation()));