Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Stupid question... is your UI code try-catching in it's call to this layer? Something has to handle that second throw...</p> <p>In a nutshell, it sounds like you're trying to do this:</p> <pre><code>using System; namespace ConsoleApplication1 { class ExceptionA : Exception { public override string Message { get { return "Exception A"; } } } class ExceptionB : ExceptionA { public override string Message { get { return "Exception B"; } } } class Program { static void Main(string[] args) { try { DoThing(); } catch (Exception ex) { Console.WriteLine("Caught in 'UI' code: " + ex.Message); } } static void DoThing() { try { throw new ExceptionB(); } catch (ExceptionB ex) { Console.WriteLine("Caught B"); throw; } catch (ExceptionA ex) { Console.WriteLine("Caught A"); } catch (Exception ex) { Console.WriteLine("Caught Generic"); } } } } </code></pre> <p>Which yields this output:</p> <p>Caught B<br> Caught in 'UI' code: Exception B<br> Press any key to continue...</p> <p>It just seems like you don't have anything catching the 2nd thrown exception, which is why it's "unhandled." If we comment out the try-catch in main, we end up with an unhandled exception:</p> <pre><code>static void Main(string[] args) { //try //{ DoThing(); //} //catch (Exception ex) //{ //Console.WriteLine("Caught in 'UI' code: " + ex.Message); //} } </code></pre> <p>Yielding the following output:</p> <p>Caught B</p> <p>Unhandled Exception: ConsoleApplication1.ExceptionB: Exception B at ConsoleApplication1.Program.DoThing() in C:\Users\Giovanni\AppData\Local\T emporary Projects\ConsoleApplication1\Program.cs:line 50 at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Giovanni\AppDa ta\Local\Temporary Projects\ConsoleApplication1\Program.cs:line 33 Press any key to continue . . .</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload