Skip to content

Instantly share code, notes, and snippets.

@adrianhsieh
Created January 17, 2014 08:09
Show Gist options
  • Select an option

  • Save adrianhsieh/8469958 to your computer and use it in GitHub Desktop.

Select an option

Save adrianhsieh/8469958 to your computer and use it in GitHub Desktop.
Sub-flow example for handling excpetion
<catch-exception-strategy doc:name="Catch Exception Strategy">
<flow-ref name="set-errorresponse-subflow" doc:name="set-errorresponse-subflow"/>
</catch-exception-strategy>
<sub-flow name="set-errorresponse-subflow" doc:name="set-errorresponse-subflow">
<set-variable variableName="jsonpmsg" value="#[exception.cause.message]" doc:name="jsonpmsgError"/>
<scripting:transformer doc:name="json-map">
<scripting:script engine="Groovy"><![CDATA[def jsonpmsg = message.getInvocationProperty('jsonpmsg');
def estatus = 500;
if (jsonpmsg.indexOf('token_rejected') > 0 || jsonpmsg.indexOf('OAuth') > 0)
estatus = 401;
def jsonmap=[status:estatus,message:jsonpmsg];
return jsonmap;]]></scripting:script>
</scripting:transformer>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<flow-ref name="status-jsonp-subflow" doc:name="status-jsonp"/>
</sub-flow>
@ngueynhoangnam

Copy link
Copy Markdown
<script src="https://gist.github.com/adrianhsieh/8469958.js"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment