The code:
public Constructor(string vConnection_String)
{
try
{
mConnection_String = vConnection_String;
}
catch (Exception ex)
{
ExceptionHandler.CatchEx(ex);
}
}
I think the person who programmed this was “just being careful,” but out of interest what exceptions could be thrown on a line that does a string assignment like this one here? I can think of System.OutOfMemoryException, but what others?
Thank you
Herb Sutter write several great articles about exception safety, and in one of them he shows 3 types of exception safety:
the basic guarantee
the strong guarantee
the nothrow guarantee
This principles are commonly known in C++ world but we could use them in .net world too because one of them takes place in your situation.
If mConnection_String is a field of type System.String (or another reference type) than you definitely know, that this code is “nothrow guarantee”, because simple assignment for reference type could not throw exceptions at all.