Try Catch Printing Exception Source

I have an activity to click image if it cannot find the image it throws an exception and source field in the exception pop up tells me exactly which image(My Display name) is throwing the exception.But when I catch that exception, exception.source property gives me system.activities as an Output.

How to get the exact source Any Ideas??

1 Like

Try exception.Tostring or exception.Message.

Both Try exception.Tostring or exception.Message says Image not found.It doesn’t say explicitly which Image

True. It seems to be a bug.I think you can capture the Displayname in a variable or hardcode in that specific exception.

@badita can you help

yes, check this here. Logging.zip (7.6 KB)

Only that it works only if the error occurs in an invoked workflow.

Therefore

  • do your actions in wf1
  • in main add try {invoke wf1;} catch(exception ex) {log ex.source};
  • run main

and it will work.

7 Likes

Thanks @badita. It worked.

So what you are saying is, if we want to have the name of the activity, we need to have all error handling in another workflow, like:

workflow: RUNME
try{
invoke main }
catch all exceptions{
Print activity name}

Is there really not smarter solution?
If not, could there be an option when starting a new project to automatically generate a file with above content?

2 Likes

Hi badita,

I appreciate your sharing knowledge for logging exception.source.

Couldn’t we log exception source when we use only 1 workflow which don’t have [Invoke workflow] ?

Regards,
Soshi

2 Likes

As of now…no. We are limited by the WF technology.

Thanks.

Hi @badita,
This solution provides us the activity name in which the exception occured.
But if I have multiple files how can I know in which file this exception occured?

Is there any solution for us to know both the below things.

  • I want to know activity name in which the exception occured
  • Also I want to know the file name in which the exception occured.

Could you help on this?

Regards,
Sree

It might be helpful to store like a destination variable before each Invoke, so you know where it is in the process. Then you can use that to know which part of the process failed and attach that with the Source and Message. However, depending on your framework, if your Try/Catch is outside of your entire process, then that destination variable will not get stored through the Arguments since Arguments are not passed in the event of an Exception, unless you maybe store your destination in a file.

1 Like