Let's consider this code :
try
{
return new ClassA.GetStuff();
}
catch (Exception e)
{
throw new MyException
("message", e)
{SomeMyExceptionProperty = "something"};
}
When throwing MyException
, how the object initialization is done? Like this :
MyException myException = new MyException("message", e);
myException.SomeMyExceptionProperty = "something";
throw myException;
or like this (so the SomeMyExceptionProperty
is not initialized) :
MyException myException = new MyException("message", e);
throw myException;
myException.SomeMyExceptionProperty = "something"; //unreachable code
I think that the first behavior is used, like for a return
statement, but where is the official documentation about this?