This project is read-only.

Suppress exceptions with comment


Sometimes exceptions are never thrown or should net be caught by the caller.
As example
if(something != null)
If have already implemented a solution for such cases.
        /// <exception cref="ArgumentException">Thrown when foo is 5</exception>
        /// <exception cref="ArgumentOutOfRangeException">Can be ignored because argument of sleep is always valid</exception>
        public void HasIgnoredExceptions(int foo)
            if (foo == 5)
                throw new ArgumentException("foo");
If a exception comment starts with "Can be ignored" this exception can be ignored by the caller.
Any Ideas for improvements?


hastarin wrote Nov 27, 2013 at 2:15 AM

There definitely needs to be a way to supress the warnings. Even if it's only because of a bug in Exceptional.
Either an attribute like StyleCop uses or, ideally a preceding comment like Resharper does.

I've only just started trying out the plugin and immediately hit two issues.
  1. The following code will never throw an exception but it wants me to catch/document it. The call to GetIsInDesignMode could throw an InvalidOperationException but only if the null.
        public static bool IsInDesignMode
                return DesignerProperties.GetIsInDesignMode(new DependencyObject());
  1. I'm actually catching Exceptions by using a general catch. I'm fully aware they are there and they get logged both within the methods themselves and within my general Exception block. They are being thrown in case a future developer visits my code base and tries to use the code incorrectly.
Ideally it should detect it's being caught via the general Exception catch block and warn you with the option to supress, again a comment would be best.

Amberg wrote Feb 6, 2014 at 7:43 AM

I've already implemented this on a fork, feel free to try it