How do I trap a REST error garcefully

2
Hi, I am using REST calls to retrieve data from another system. It all works just fine provided that the other system is not down. I can see the following from the Console: Log Level: Trace Log node: REST Consume Message: HTTP/1.1 200 OK followed by: Log Level: Error Log node: Connector Message: An error has occurred while handling the request.  Stack trace: com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: Error parsing JSON. Unexpected character ('<' (code 60)):   I know the system is down, because I never started it, but how do I use the Error Event (or something else) to trap it gracefully? Thanks, Guislain
asked
4 answers
4

Guislain -

Use your right mouse button on the microflow action and select set error handling.  Pick Custom (with or without rollback) and then connect your error handler to the microflow action.  Finally, use your right mouse button on the arrow that is the error handler and select Set as Error Handler.  If your error occurs in a submicroflow, you may want to create the error handling inside of that microflow for more granular error handling.

These documentation links may be helpful:

https://docs.mendix.com/howto/logic-business-rules/set-up-error-handling#1-introduction

https://docs.mendix.com/refguide/microflows#3-notation

Hope that helps,

Mike

answered
2

Hi Guislan,

  Have you added Error Handling to the REST action that makes the call? When you do this, you can define an error flow and in that flow create your own logging node. There you can use the $latestError variable to print out the message and stacktrace specifically for your REST call. This is the best way to get information to your log when you hit an error.

 For more information on how to do this, check out this how-to and learning path:

https://gettingstarted.mendixcloud.com/link/path/5

and

https://docs.mendix.com/howto/logic-business-rules/set-up-error-handling#5-best-practices

 

answered
0

Hi Rob,

Thank you for the quick response as well as the 2 sources.

I do not see how to adorn a microflow with (error) event

with an outgoing (error handling) flow (BPMN- like).

More than one flow shows an error. 

How do I that?

Thanks again,

Guislain

answered
0

Hi Mike,

That did it!

Setting the error handling as “Custom w/o rollback”, I have my 2 custom messages (1 user-friendly, the other more techy with REST stuff), albeit the generic one remains.

How do I suppress the generic one?

Thank you very much!

Guislain

answered