-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consistent Exception handling v3 #1143
Conversation
because InternalLogger checks MustBeRethrownImmediately and MustBeRethrown logs as fallback
Current coverage is
|
@bhaeussermann Do like to check this again? I didn't changed any plans since our nice discussion :) |
if (ex != null) | ||
{ | ||
ex.MarkedAsLoggedToInternalLogger(); | ||
formattedMessage += " Exception: " + ex.ToString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding the exception string to the StringBuilder
below instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, thanks!
but that's OK as this is new in 4.3 and the type is still the same.
I was wrong :) The |
If you like to check this again, thanks! I rechecked every call to |
@@ -72,12 +72,13 @@ public void ScanTypes(Type[] types, string prefix) | |||
} | |||
catch (Exception exception) | |||
{ | |||
InternalLogger.Error(exception, "Failed to add type '{0}'.", t.FullName); | |||
|
|||
if (exception.MustBeRethrown()) | |||
{ | |||
throw; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must this not change to MustBeRethrownImmediately
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you think that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only reason would be backwardscomp. I think it's bug that the exception was not thrown when throwExceptions=true
Ok, so I assume that it is then safe to throw an exception where we did not throw an exception before if |
} | ||
|
||
|
||
|
||
[Fact] | ||
public void InvalidLoggerConfiguration_ThrowsConfigurationException_IfThrowExceptionsFlagIsSet() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name should say IsNotSet
.
Consistent Exception handling v3
Summary
Preferred way to use:
InternalLogger.Warn
or InternalLogger.Error`eg. (most preferred)
Also OK, but no custom message in the logs:
Only in special cases! (legacy, very good reaons)
Never use
throw ex
Original post
Fixes that:
Fixes #637. Fixes #277
supersedes #915 and #1117
todo
mustBeRethrow
cases