Skip to content

Gendarme.Rules.Exceptions.DoNotThrowReservedExceptionRule(2.10)

Sebastien Pouliot edited this page Jan 15, 2011 · 3 revisions

DoNotThrowReservedExceptionRule

Assembly: Gendarme.Rules.Exceptions
Version: 2.10

Description

This rule will fire if an System.ExecutionEngineException, System.IndexOutOfRangeException, NullReferenceException, or System.OutOfMemoryException class is instantiated. These exceptions are for use by the runtime and should not be thrown by user code.

Examples

Bad example:

public void Add (object obj)
{
    if (obj == null) {
        throw new NullReferenceException ("obj");
    }
    Inner.Add (obj);
}

Good example:

public void Add (object obj)
{
    if (obj == null) {
        throw new ArgumentNullException ("obj");
    }
    Inner.Add (obj);
}

Notes

  • This rule is available since Gendarme 2.0

Feedback

Note that this page was autogenerated (1/15/2011 12:27:16 PM) based on the xmldoc comments inside the rules source code and cannot be edited from this wiki. Please report any documentation errors, typos or suggestions to the Gendarme Google Group. Thanks!

Clone this wiki locally