# Knowing unhandled exceptions from a test step

**URL:** https://forum.opentap.io/t/knowing-unhandled-exceptions-from-a-test-step/2492
**Category:** Technical
**Tags:** opentap-sdk, ks8400-editor
**Created:** [June 26, 2025, 5:41pm UTC](https://forum.opentap.io/t/knowing-unhandled-exceptions-from-a-test-step/2492 "2025-06-26T17:41:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![antonio.quizon](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@antonio.quizon](https://forum.opentap.io/u/antonio.quizon)
#### Post date: [June 26, 2025, 5:41pm UTC](https://forum.opentap.io/t/knowing-unhandled-exceptions-from-a-test-step/2492/1 "2025-06-26T17:41:37Z")

</div>

Hi everyone,

We are trying out some work with test steps. We know that when we face or throw an exception during a TestStep.Run(), the execution will stop. Is there a way we can know how what exception was thrown? or handle it?

Would appreciate some inputs, thanks!

---

<div class="post-metadata">

### Author: ![rolf\_madsen](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rolf\_madsen](https://forum.opentap.io/u/rolf_madsen)
#### Post date: [June 27, 2025, 11:42am UTC](https://forum.opentap.io/t/knowing-unhandled-exceptions-from-a-test-step/2492/2 "2025-06-27T11:42:01Z")

</div>

Hi @antonio.quizon, The best way to know which exceptions are thrown is by looking in the log file. The best way to handle exceptions is using try/catch.

Since you ask, maybe thats because you cannot use either of those options, but there might be other things you can do. Can you elaborate a bit more on the specific situation?

---

<div class="post-metadata">

### Author: ![scottri](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@scottri](https://forum.opentap.io/u/scottri)
#### Post date: [June 30, 2025, 5:44am UTC](https://forum.opentap.io/t/knowing-unhandled-exceptions-from-a-test-step/2492/3 "2025-06-30T05:44:31Z")

</div>

Our step’s run looks like this:

```csharp
    public class MyTest: CustomTestStep
    {
        ...

        public override void Run()
        {
            try
            {
            }
            catch (Exception ex)
            {
                UpgradeVerdictToError($"Step '{Name}': {ex.Message}", ex);
            }
        }
        ...

```

and we use this in our derived class off of TestStep so that we have an easy way to invoke it and a single place to change it in the future.

```csharp
    public class CustomTestStep : TestStelp
    {
       ...

        /// <summary>
        /// Sets the Verdict to Error and logs the error message and exception if provided.
        /// </summary>
        /// <param name="errorMessage">Message to log, will use exception if null or empty</param>
        /// <param name="exception">Exception if any</param>
        /// <param name="rethrow">Rethrow exception if any</param>
        /// <param name="caller">Caller of this method</param>
        public void UpgradeVerdictToError(string errorMessage, Exception exception = null, bool rethrow = false, [CallerMemberName] string caller = "")
        {
            if (exception != null)
            {
                Log.Debug($"{caller}: {exception}");
                if (errorMessage == null || errorMessage.Length == 0)
                    errorMessage = exception.ToString();
            }
            Log.Error(errorMessage);
            UpgradeVerdict(Verdict.Error);
            if (rethrow)
                throw exception;
        }
        ...
     }

```
