-
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
Improve exception handling (make it consistent and clear) #915
Conversation
…nHelper refactored occurrences of MustBeRethrown()
How can I actually start the tests from command line? Since the VS test runner creates bin/ and obj/ directories which bother source code tests. |
Well, I nearly expected something like this, when I left out the configuration exception. So... back to scratch. |
Looks really good! 2 things I'm thinking we maybe should handle :
|
Msbuild NLog.proj /t:runtests? (now on mobile) |
Maybe you can pass the expected exception as type argument? Eg
PS still on mobile. Ignore the syntax errors :p |
So, I'm sort of back after some time at work. |
An idea I head was something like a wrapper |
Yes you're right! I forgot that
Not sure if this is nice, but...
This is a nice idea! No need for a cast I think, we can create a ShouldThrows() in edit: this would be a breaking change. Still thinking if we can fix this otherwise.... |
Or maybe something like: and
|
Thinking of this from scratch: bool shouldThrow = ex.LogException();
if(shouldThrow) throw; but then we're almost back... ( |
It seems it would be a breaking change in any way we consider it useful. So spare it for later? Just fix the problematic occurences? |
Well not if we extend/rename the We get really soon complains if introduce a breaking change ;) |
If we just extend it the way I tried, we will break some tests that rely on specific exceptions to be thrown, which were the reason for me thinking about adjusting/extending the tests by accepting this wrapper exception. Since we cannot properly rethrow a catched exception outside the catch-block, we're stuck between redesign (breaking change) and very little changes. |
Agree with this. I'm doubting if there will be a huge benefit for the breaking change (compared to the little change) - yes it looks better, but every change in an unit test will result in changes needed by our users. So if we can fix it without breaking change, that's preferred, despite I really liked our approach. |
To summarize, by now we are at something like this: if(ex.LogAndCheckRethrow()) throw; aren't we? |
Yes, I think that is the best option. Sehr schön! :p |
Need some help on this @tetrodoxin ? |
I'm abroad these days and seldom online, will be back next week, at the latest. -------- Original Message -------- Need some help on this @tetrodoxin ? Reply to this email directly or view it on GitHub: #915 (comment)Andreas Hübner |
OK thanks for the info! |
new method MustRethrowSevere
…exception_handling
fixed file header
Current coverage is
|
I had to adjust one test class, namely VariableLayoutRendererTests, because it did not fit into the 'expected exception behavior'. It wasn't prepared for exceptions being rethrown, although it was activated in config. |
Thanks! I checked the code and have some questions:
I don't fully understand this. Should we change the unit tests for this?
|
N.P. Changed that.
Oh, I just missed that one. Was a relict of several changes in the code/tries around it.
Actually, the mistake was, that |
Well, I should have hit on it myself. I changed |
Yes and no. |
I guess you mean |
Fixed exception handling/logging in InternalLogger
…rodoxin/NLog into issue_277_exception_handling
I must admit, I have no idea why |
Ok, I can see you changed right this code :-) |
let me know when I can review it again :) Thanks! |
I was thinking about this. Is Error level not the best way for exceptions? (for all)? |
I think #1040 broke this PR :( |
If you added as me collaborator, I can help fixing the last stuff. Just let me know. |
bit busy on other stuff, will look at this next week |
superseded by #1117 |
@tetrodoxin I like to have this in 4.3, so I'm busy fixing the conflict and some loose ends. Thanks for the PR! |
I am really sorry for being absent that last couple of months and I hope, you at least could make some use of the code snippets, we worked out last year. |
Yes, we did :) This feature has been merged in 4.3 Thanks for the contributions! |
and refactored respective occurrences.
It's the first shot and definitely object to discuss, but I had to start somewhere.