Hi I logged a JIRA to improve this https://issues.apache.org/jira/browse/CAMEL-5262
On Wed, May 9, 2012 at 12:25 PM, Claus Ibsen <claus.ib...@gmail.com> wrote: > Hi > > You can reconfigure the simple language to use different start/end tokens. > > But that said, we should probably relax the check for token pairs to > not complain for end tokens } without a starting token ${. > As thats the case in your JSON example. > > Likewise we could consider having an escape character so you can do \} > to escape the end token to make it explicit. > And maybe for the start tokens as well, but thats a bit odd as most > people would never want ${ as output, eg \$\{ > > > > On Wed, May 9, 2012 at 11:44 AM, David Geary <david.ge...@aepona.com> wrote: >> Hi we have a route in camel for an HTTP Rest endpoint that returns JSON with >> the following exception handling to convert exceptions in the route to JSON >> >> <onException> >> <onException> >> >> <exception>org.springframework.security.access.AccessDeniedException</exception> >> <handled> >> <constant>true</constant> >> </handled> >> <setHeader headerName="CamelHttpResponseCode"> >> <constant>403</constant> >> </setHeader> >> <setHeader headerName="Content-Type"> >> <constant>application/json</constant> >> </setHeader> >> <process ref="oAuth2TokenRevokeProcessor"/> >> <transform> >> <simple>{"error":"${exception.message}"}</simple> >> </transform> >> </onException> >> </onException> >> >> This was previously working, but has stopped working since we upgraded to >> camel 2.9.0 - we now get this exception >> >> org.apache.camel.language.simple.types.SimpleIllegalSyntaxException: >> functionEnd has no matching start token at location 31 >> {"error":"${exception.message}"} >> * >> >> at >> org.apache.camel.language.simple.SimpleExpressionParser.parseExpression(SimpleExpressionParser.java:50)[115:org.apache.camel.camel-core:2.9.0.fuse-beta-7-042] >> at >> >> It seems camel no longer likes the closing curly bracket. >> >> So instead i tried using SPEL: >> >> <transform> >> <spel>{"error":"#{exception.message}"}</spel> >> </transform> >> >> But this fails with >> >> org.apache.camel.ExpressionEvaluationException: >> org.springframework.expression.spel.SpelEvaluationException: EL1007E:(pos >> 10): Field or property 'message' cannot be found on null >> >> Ie SPEL cannot seem to see the exception even though the documentation for >> SPEL in camel says it should be avaliable. >> >> In the end we have it working like this: >> >> <transform> >> <simple>${exception.message}</simple> >> </transform> >> <transform> >> <spel>{"error":"#{request.body}"}</spel> >> </transform> >> >> But this seems overkill for such a simple case - is there a simpler way to >> do this? >> >> Should the simple expression fail the way it does with a closing curly >> bracket - this was OK before and obviously causes issues in JSON >> >> Why does SPEL think the exception is null? >> >> >> -- >> View this message in context: >> http://camel.465427.n5.nabble.com/Translating-route-exceptions-to-JSON-with-Simple-Expression-Language-or-SPEL-tp5696933.html >> Sent from the Camel - Users mailing list archive at Nabble.com. > > > > -- > Claus Ibsen > ----------------- > CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ -- Claus Ibsen ----------------- CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/