It is discouraged to simply catch System.Exception, instead only the "known" Exceptions should be caught.
Now, this sometimes leads to unneccessary repetetive code, for example:
try
{
WebId = new Guid(queryString["web"]);
}
catch (FormatException)
{
WebId = Guid.Empty;
}
catch (OverflowException)
{
WebId = Guid.Empty;
}
I wonder: Is there a way to catch both Exceptions and only call the WebId =
Guid.Empty call once?
Vijay Shukla
13-Jun-2013Hello Pravesh Singh!
Catch System.Exception and switch on the types