-
Notifications
You must be signed in to change notification settings - Fork 56
Reusing the Error Codes #105
base: master
Are you sure you want to change the base?
Reusing the Error Codes #105
Conversation
…es with a List. This allows for duplicates of the error codes to be present. This is important to support validation errors that might have the same error code on multiple fields. The refactoring introduced the ErrorWithArguments class which combines the previous errorCodes field with the arguments field. This refactoring avoids the potential mismatch between what is the errorCodes field and the map's keys.
Codecov Report
@@ Coverage Diff @@
## master #105 +/- ##
============================================
- Coverage 93.58% 91.60% -1.98%
- Complexity 296 298 +2
============================================
Files 34 35 +1
Lines 701 715 +14
Branches 85 87 +2
============================================
- Hits 656 655 -1
- Misses 25 37 +12
- Partials 20 23 +3 Continue to review full report at Codecov.
|
@wimdeblauwe Thank you. I will look at them in the upcoming days. |
@alimate Have you been able to look at this? |
@wimdeblauwe I could not manage to find a time. |
@wimdeblauwe This looks really nice, I'd say that we can go this way. My only concern are changes to public API of FYI @alimate |
This will allow users of HandledException to smoothly upgrade since the HandledException is a public API exposed via WebErrorHandler.
@zarebski-m I have re-instantiated the public methods of There are only 2 unit tests left: On a side note: I find that the test with the parameters are a bit annoying if you need to debug since there is no easy way to run a single test with a specific set of parameters that fails. |
@wimdeblauwe It's better, but I'd like to mention that constructors are also part of public API. ;) It's especially important here because |
Constructors are back :) For
I get:
Is the test really valid as it was before? Because there where more keys in the errorCodes then there are keys in the map with the errorCode -> arguments. With this new setup, this mismatch is no longer possible. The validation annotations on Person look like this:
So for me it is normal that there is a 2nd list of arguments. Can I change the test in that direction? |
To make the tests better fit with the updated design of
What I did is replace the arguments of IMO it makes it more readable and you can't have a mismatch between the Set and the Map. Do you like this? Do you want me to change all tests like that? Or do you want this on a separate branch? |
@wimdeblauwe Thanks for your changes, I really like them. Regarding test cases: your changes definitely make sense to me and indeed are more readable. I'm not sure about rewriting all the tests, though; not in this PR at least. I'd suggest to make minimal effort to keep current tests working as they are, and possibly rewrite them in another PR. Changes in business logic and overhaul of tests in one go can unintentionally introduce regressions. |
@zarebski-m Seems like the best to do it in a separate PR indeed to me as well. I think I only need an answer to #105 (comment) in order to finish the PR? |
@wimdeblauwe It seems to me that this test case could indeed be wrong. There should be two sets of arguments, one for each violated constraint. |
Ok, final test also fixed. This is now ready to be fully reviewed (and hopefully merged :-) ) |
Can we progress on this? Is there anything else that is needed? |
@alimate Could you have a look at this PR? |
Friendly reminder @alimate |
@wimdeblauwe I'm terribly sorry about these recurring delays. I was swamped for the last 5 months! Cheers! |
@alimate Looking forward to it :-) |
Any update on this? |
Honestly, I'm terribly sorry for these sort of delays. I completely understand that you invest your valuable time on this and you have every right to follow up. Again, I'm sorry that I can't find the time to contribute more. |
Are you saying that it would be better for me to fork the project if I want to get my changes in a published version? Or is it possible to share the maintenance load of the project with somebody else? Maybe @zarebski-m ? |
For now, forking it seems to be a better option. |
Ok, no problem. I totally understand. This has lead me to think hard about what I want from error handling and there are quite a few things I'd like differently. Due to that, I started my own project at https://github.com/wimdeblauwe/error-handling-spring-boot-starter It is certainly not as feature-rich as yours, but it is more closely aligned with my needs. So you can close this PR as I will not further work on this, as I now have my own project to take care of. :) Good luck with your project! |
…es with a List.
This allows for duplicates of the error codes to be present. This is important to
support validation errors that might have the same error code on multiple fields.
The refactoring introduced the ErrorWithArguments class which combines the previous
errorCodes field with the arguments field. This refactoring avoids the potential
mismatch between what is the errorCodes field and the map's keys.