I'm having the slight issue that spring boot is providing me with absolutely convoluted error messages, which none of my customers can or will understand.
for example:
this is my property configuration class
@Component
@ConfigurationProperties(prefix = "input")
class WorkflowRunnerProperties{
@Valid
@NotNull(message = "please provide a file containing your targets for the parameter --input.libraryTargets")
val libraryTargets:File = null
@Valid
@NotNull(message = "please provide a file containing your targets for the parameter --input.correctionTargets")
val correctionTargets:File = null
}
And during start up I receive this error message:
ERROR [main] SpringApplication - Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workflowRunnerProperties': Could not bind properties to WorkflowRunnerProperties (prefix=input, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 2 errors Field error in object 'input' on field 'correctionTargets': rejected value [null]; codes [NotNull.input.correctionTargets,NotNull.correctionTargets,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [input.correctionTargets,correctionTargets]; arguments []; default message [correctionTargets]]; default message [please provide a file containing your targets for the parameter --input.correctionTargets] Field error in object 'input' on field 'libraryTargets': rejected value [null]; codes [NotNull.input.libraryTargets,NotNull.libraryTargets,NotNull]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [input.libraryTargets,libraryTargets]; arguments []; default message [libraryTargets]]; default message [please provide a file containing your targets for the parameter --input.libraryTargets] at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:339) at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:289) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) ...
which is nice, but provides so many information that it defeats the purpose, instead all I want to see is:
please provide a file containing your targets for the parameter --input.correctionTargets please provide a file containing your targets for the parameter --input.libraryTargets
what would be the easiest way to catch this exception and only log the actual relevant information for the user, without overwhelming him with all the developer stuff.
thanks