It’s good to handle any exception that could be raised in some useful way. Frequently, this means that you need to take advantage of the catch block’s ability to filter by type so you can do something different in each case. Or you could do what Adam‘s co-worker did.
try
{
/* … some important code … */
} 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 that if they ever need to add different code paths, they’re halfway there.
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
Source: Read MoreÂ