C
csharper
I keep on reading about how bad it is to catch Exception instead of a more particular SomeKindOfException. But a method can potentially throw a dozen of concrete exceptions. Are we really supposed to chain a dozen catches like so?
try
{
SomeMethodThatThrowsDozensOfExeptions();
}
catch(Exception1 ex)
{
// handle it
}
catch(Exception2 ex)
{
// handle it
}
catch(Exception3 ex)
{
// handle it
}
catch(Exception4 ex)
{
// handle it
}
catch(Exception5 ex)
{
// handle it
}
catch(Exception6 ex)
{
// handle it
}
catch(Exception7 ex)
{
// handle it
}
....
catch(Exception_n ex)
{
// handle it
}
try
{
SomeMethodThatThrowsDozensOfExeptions();
}
catch(Exception1 ex)
{
// handle it
}
catch(Exception2 ex)
{
// handle it
}
catch(Exception3 ex)
{
// handle it
}
catch(Exception4 ex)
{
// handle it
}
catch(Exception5 ex)
{
// handle it
}
catch(Exception6 ex)
{
// handle it
}
catch(Exception7 ex)
{
// handle it
}
....
catch(Exception_n ex)
{
// handle it
}