Thank you! This worked for me:
onException(BadHeaderException.class)
.handled(true)
* .transform(simple("Bad API request: ${exception.message}"))*
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400))
2018-02-02 11:33 GMT+02:00 Claus Ibsen :
> Hi
>
> The configure method in the RouteBuilder
Hi
The configure method in the RouteBuilder is only invoked once to setup
the routes.
And constant is creating a constant message.
So what you need to do is to use simple instead to tell Camel to build
a dynamic message with the exception message
See the docs at: http://camel.apache.org/simple
I have the following global onException clause in my RouteBuilder configure
method:
onException(BadHeaderException.class)
.handled(true)
.transform(constant("Bad API request: " + exceptionMessage()))
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(400))
The route is as follows:
from(String.form