Users Pricing

forum

Home Forums Catch multiple Exceptions at once? – MindStick

Catch multiple Exceptions at once?

Pravesh Singh 2787 13 Jun 2013

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?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md