Gotta Catch Them All – The Daily WTF

It’s a good idea to handle any exception that might be raised in some useful way. This often means you need to take advantage catch the ability of the block to filter by type so you can do something different in each case. Or you can do what Adamhis associate did.

try


 catch (OutOfMemoryException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (OverflowException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (InvalidCastException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (NullReferenceException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (IndexOutOfRangeException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (ArgumentException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (InvalidOperationException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (XmlException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (IOException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (NotSupportedException exception) 
        Global.Insert("App.GetSettings;", exception.Message);
 catch (Exception exception) 
        Global.Insert("App.GetSettings;", exception.Message);

Well, I guess they’re halfway there, if they ever need to add different code paths.

[Advertisement]

BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Find out how!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *