Skip to content

Gendarme.Rules.BadPractice.CheckNewExceptionWithoutThrowingRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

CheckNewExceptionWithoutThrowingRule

Assembly: Gendarme.Rules.BadPractice
Version: 2.10

Description

This rule checks for exception objects which are created but not thrown, not returned, and not passed to another method as an argument.

Examples

Bad example:

void MissingThrow (object arg)
{
    if (arg == null) {
        new ArgumentNullException ("arg");
    }
    DoWork (arg);
}

Good examples:

void Throw (object arg)
{
    if (arg == null) {
        throw new ArgumentNullException ("arg");
    }
    DoWork (arg);
}
Exception CreateException ()
{
    return new Exception ();
}
Clone this wiki locally