4 ms·
Honest question, I'm not familiar with C#: would putting the Log in the finally clause not have the same behaviour? That is, bool _operation_X_success = fals
by anon4 12y ago
Honest question, I'm not familiar with C#: would putting the Log in the finally clause not have the same behaviour? That is,
bool _operation_X_success = false;
try {
...
_operation_X_success = true;
} finally [
if (!_operation_X_success) {
Log("blah blah");
}
}
- SideburnsOfDoom 12y agoThe finally clause does not have access to the exception details, as it executes regardless of whether there is an exception or not. You can't do "Log(ex);" in the finally block. And you would want to put the exception into the log. You also need a boolean and a few extra lines of control code as your example shows.