Consider these two methods
public int GetSomething(object obj)
{
Contract.Requires<ArgumentNullException>(obj != null);
...
}
public int GetSomethingWrapper(object anotherObj)
{
var obj = GetObj(anotherObj);
return GetSomething(obj);
}
Let's consider GetObj
to be safe i.e. it doesn't throw any exceptions.
Thus GetSomething
and GetSomethingWrapper
throw execption if obj is null. But in the latter case the origin of exception is GetSomething
method.
The question is whether I'd add checks for GetSomethingWrapper
?
One the one side: not its business to care about. On the other: both methods are public but caller of the wrapper method has no contract information.