Created
January 17, 2014 08:09
-
-
Save adrianhsieh/8469958 to your computer and use it in GitHub Desktop.
Sub-flow example for handling excpetion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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
commented
May 30, 2018
<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