Typically, exception handling will look like this:
public class EntryPointClass
{
Logger _logfile;
public void DoIt(string Data)
{
var logicClass = new MyClass();
try
{
logicClass.DoSomething(Data);
}
catch(NullReferenceException ex)
{
_logfile.WriteLine("null reference exception occured in method 'DoIt'");
}
}
}
(Logger - , , , MyClass. - .)
MyClass ( , , , ).
, TDD. , MyClass , -, . , . , , unit test MyClass, MyClass .
, , EntryPointClass , - , . , , constrcution, ILogger, . , :
public class EntryPointClass
{
catch(NullReferenceException ex)
{
if(_logfile!=null)
_logfile.WriteLine("null reference exception occured in method 'DoIt'");
}
}