In C# you can catch any exception with
try
{
throw new SomeException();
}
catch
{
// handle exception...
}
If you need to have access to the exception object during the catch block (to look at its message or wrap it in another exception to rethrow or whatever) you can do
try
{
throw new SomeException();
}
catch (Exception ex)
{
// handle exception...
}
Since all exception objects inherit from the Exception class that catch block will execute no matter what exception gets thrown in the try block.