Proper exceptions to use for nulls
Posted
by user200295
on Stack Overflow
See other posts from Stack Overflow
or by user200295
Published on 2010-05-21T18:54:23Z
Indexed on
2010/05/21
19:00 UTC
Read the original article
Hit count: 197
c#
|exception-handling
In the following example we have two different exceptions we want to communicate.
//constructor
public Main(string arg){
if(arg==null)
throw new ArgumentNullException("arg");
Thing foo=GetFoo(arg);
if(foo==null)
throw new NullReferenceException("foo is null");
}
Is this the proper approach for both exception types?
© Stack Overflow or respective owner