Does using the 'catch, when' feature make exception handling faster because the handler is skipped as such and the stack unwinding can happen much earlier as when compared to handling the specific use cases within the handler? Both constructs (catch () being a syntax error, as sh4nx0r rightfully pointed out) behave the same in C#. The fact that both are allowed is probably something the language inherited from C++ syntax.

Understanding the Context

, can throw objects that do not derive from System.Exception. In these languages, catch will handle those non-CLS exceptions, but catch (Exception ... catchResult is the result of the few lines of code. It's not actually the result of the catch command itself.

Key Insights

catch returns zero (a false value) to mean "no errors" and a non-zero value to mean "errors occurred". See this extensive example in the Tcl Wiki page for exec. write-host 'CommandNotFoundException' } catch { write-host 'well, darn' } That output 'CommandNotFoundException' correctly. I vaguely remember reading elsewhere (though I couldn't find it again) of problems with this. In such cases where exception filtering didn't work correctly, they would catch the closest Type they could and then use a switch.

Final Thoughts

Note that most crashes are not caused by exceptions in C++. You can catch all exceptions, but that won't prevent many crashes. I think that this only works if you raise and then catch the exception, but not if you try getting the traceback before raising an exception object that you create, which you might want to do in some designs. 80 I'm a student in my first C++ programming class, and I'm working on a project where we have to create multiple custom exception classes, and then in one of our event handlers, use a try/catch block to handle them appropriately. My question is: How do I catch my multiple custom exceptions in my try/catch block? Would an catch (Exception e) catch an SQL exception?

Or is it mandatory to use catch (SqlException e)? Because somehow catch (Exception e) does't catch "SqlException: Cannot insert duplicate key row".