I'm struggling to understand how passing a variable stored in the body as a parameter of throwException. This is my code:
.when(simple("${body[errorCode]} contains '101'"))
.throwException(new IllegalArgumentException(
"Action not allowed- Error code:" + ${body[errorCode]))
.otherwise()
When I run the application the message passed to ErrorHandling is
'Action not allowed- Error code:${body[errorCode]', no replacing for errorCode variable.
Any suggestions? Tnks.
So you are using the Simple language in Java but you have some syntax issues. Nothing major. Your do not complete the delimiter of the Simple expression. Also you dont have to concatenate the string.
Change the code:
To: .throwException(new IllegalArgumentException("Action not allowed- Error code: ${body[errorCode]}"))
I am on the buss and using my phone so can't check if the code runs but it should point you in the right direction.