Best way to handle exceptions in C#....?

Unfortunately I can't install Visual Studio on the server so can't debug my C# code from Outsystems.

I have a scenario whereby an action written in C# works in one module but not in another using identical code (I literally cut and pasted it and there is nothing in either preparation that would make any difference).  The code also works when running it on the data downloaded locally from directly within Visual Studio, plus I can run other C# actions on the same data (i.e. file) from within the module that the original C# action doesn't work in.  It's just that one action that doesn't work in that one module but it works in all other modules.

I want to add some error handling in the C# code but not sure of the best way to integrate it for Outsystems.  Can anyone advise please?

Sienna wrote:

Unfortunately I can't install Visual Studio on the server so can't debug my C# code from Outsystems.

I have a scenario whereby an action written in C# works in one module but not in another using identical code (I literally cut and pasted it and there is nothing in either preparation that would make any difference).  The code also works when running it on the data downloaded locally from directly within Visual Studio, plus I can run other C# actions on the same data (i.e. file) from within the module that the original C# action doesn't work in.  It's just that one action that doesn't work in that one module but it works in all other modules.

I want to add some error handling in the C# code but not sure of the best way to integrate it for Outsystems.  Can anyone advise please?

Have you checked the Error and Extension logs? Exceptions in extensions are logged automatically, so there may be useful info there in terms of what is happening, and why, including the stack trace.

Beyond that, you can leverage the logging component to write from the Extension to the OutSystems logs, so when an exception occurs inside the extension code, you can log additional information.

You may find this thread useful...though it has some older posts, there's a more recent post with updated syntax for logging from within an Extension: https://www.outsystems.com/forums/discussion/2737/tip-auditing-from-inside-extensions/

You may also want to debug your OutSystems app, and ensure that, in fact, any and all inputs to your extension method are the same in both places. If you set a breakpoint on the call to the extension, and examine the locals (input parameters, local variables, aggregates, etc.) you may find that there is something different.


Thanks for your reply, although I have sorted the problem now, I'd still like to add some exception handling by writing to the Outsystems logs, so thank you for that link.

I had checked the Service Centre error log but wasn't even aware that the extension also had a log, is that something separate to the Service Centre error logging as I'm not able to see anything within Integration Studio?

And for the record everything was identical, all parameters, variables, aggregates, etc..  What I did to resolve the problem was literally copy and paste the entire contents of the module into a new module and it worked.  I did absolutely nothing else other than a copy and paste, so I've no idea what the problem could have been - very weird!!