How to capture the exception window being rethrown in the Try-Catch?




I have a try-catch activity designed like this:

I would like to screen capture the exception message together with the look of the environment when exception is thrown.
However, as the exception window holds the execution thread, it will never go to “Take screenshot” activity until I close the exception window, then I won’t be able to capture the exception window.
Tried “Parallel Activity” and it didn’t work as those so-called ‘parallel’ processes are executed in sequential order (just in random order) so the exception window will still hold the thread.

Any idea that I can achieve this?

Ben Wong


Hello @ben.wong,

Try to put Rethrow activity in the last place (after saving the image)



Yes, try to change the sequence of your Take screenshot activity as @Susana suggested.
You can use a try catch for the Take screenshot activity again inside catch block.If something goes wrong while taking screenshot, then you can catch that inside the catch block of take screenshot activity and write using a writeline.

Just give a try.


Hi @Susana & @jibanjyoti ,

I think both of you misunderstood my question.
I want to capture a screenshot with Current Desktop + Error Message Info
Using rethrow is a bad idea, let’s assume we use Message box to print out the exception message.
I can take screenshot without any problem, so no need to put another try-catch.

The problem is how to take a screenshot “when the message box is not dismissed” and get this:

Let’s take this scenarios:
Call message box --> screenshot ==> in this case I have to dismiss the message box before the screenshot is taken, so no message box in my captured diagram
Screenshot --> Call message box ==> in this case screenshot is taken before message box pops up, so no message box in my captured diagram too

Any idea?


Did you get a response on this? I’m actually wanting to add this to my processes and just digging into it at this time.


@tmartin and @ben.wong

You can do this using the variable “exception” that is used inside the Catch.
For example,
exception.Message will return the error message
exception.Source will return the activity where the error occurred (but only works from an Invoke activity from my understanding)
You can also choose to store the exception to an exception type variable and capture the message at another point in the workflow.

That’s how I’m currently capturing the error.

  1. Invoke .xaml in a Try/Catch
  2. Store variable to = “[”+Now+"] "+"NameOfWorkflow: “+exception.Source+”: "+exception.Message
    or something like that
  3. Take Screenshot and Save Image
  4. Optionally, go to Retry Sequence that increments retry counter
  5. Close Workspace/apps
  6. Start section of process again or exit (or move to next transaction) if max retries have occurred.
  7. If retries were unsuccessful on last transaction attempted then Throw the error that was captured using Throw activity with BusinessRuleException