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