Try Catch activity for Run Query

I am trying to do a query in a data warehouse using the Run Query activity. I have this error message appears when the activity times out: “Run query: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.”

I want to be able to do activities when the query times out and have tried to use the Microsoft.Data.SqlClient.SqlException as the exception type in the try catch but it won’t go through that error catch path.

Any another way for me to try and catch this error?

Hi @redanime94,
I know this is not the best practice, but can you try using a more general form of Exception - System.Exception so that it catches all the errors and you can write your own logic to handle this?

Let me know if this helps

Thanks,
Nishant

Hello @redanime94 - The defined exception Microsoft.Data.SqlClient.SqlException in the catch is not the one that it was giving during run time. Hence, it was not able to catch that error. Can you try defining system.exception in the catch block and see how it goes

hi, i have tried this and had an if statement that will check if the exception message contains “Execution Timeout Expired” but to no avail. It still wouldn’t go in that loop.

I have tried almost all the possible exception options but to no avail…

Maybe the error message isn’t “Execution Timeout Expired”. As per your screenshot, can you add a log message (with your Exception message) in your System.Exception catch sequence and verify if you are getting any logs for this

@redanime94 Try to keep message boxes in all the catch blocks and then run the code in debug mode to see in which block the bot was trying to execute

This is the log message that I get:
Run query: Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Yup - I always run my bot using Debug to see where the issue is coming from. For this it’s stopping and highlighting the Run query activity.

if possible please share that screenshot

When you run in “Debug” mode, it will always stop at the Activity causing an issue. Only when you click on “Continue”, will it go to the Catch block