If I try to call a service in xml-script that has missing required input parameters, a ServiceException is thrown and the call returns to the browser with a 200 status. I don't see how I am supposed to catch the error or otherwise deal with it. Do I need to test for completeness before calling the service? And why doesn't a 500 level status get generated and returned?
Asked
Active
Viewed 84 times
0
-
Would you add more information such as how the service is called? For example, if this is in a transition what does the transition definition look like and how are you calling the transition: to process input and redirect to a view screen, to get data for a JavaScript client, etc? – David E. Jones Mar 31 '14 at 03:12
1 Answers
0
When script went wrong, error is added messageFacade, so you may detect whether the xml-script in transition or service has error via ec.message.hasError(). If there is logic error instead of exception in script, you are supposed to add error to messageFacade by yourself.
Then before return the response to client, you shall check ec.message.hasError() in a conditional-response and use ec.web.response.setStatus() to return whatever code you want (500 in your case)
<transition name="createSample">
<actions>
... some service-call or xml-actions ...
<if condition="ec.message.hasError()">
ec.web.response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR)
</if>
</actions>
<conditional-response type="none">
<condition>
<expression>ec.message.hasError()</expression>
</condition>
</conditional-response>
<default-response url="."/>
</transition>

Jimmy Shen
- 240
- 1
- 12