-
Notifications
You must be signed in to change notification settings - Fork 680
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
Refactor ValidationError
#2406
Merged
Merged
Refactor ValidationError
#2406
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
88f2b34
InternalError -> Internal
eagr 2db1699
InvalidCandidate -> Invalid
eagr 9dcbab5
InvalidCandidate::PrepareError -> ValidationError::Preparation
eagr f74a2ef
+ ValidationError::PossiblyInvalid
eagr 2d4645b
panic when missing default stack limit
eagr 361a099
InvalidCandidate::JobError -> PossiblyInvalidError::JobError
eagr 553a854
Merge branch 'master' into refactor-validation
eagr 5d1d445
fixes
eagr 01a31ae
as per advices
eagr 3dc3521
it ain't broke don't fix it
eagr 0f1cb11
provide proof
eagr 10f6766
spell out all variants
eagr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry to be pedantic, again but maybe instead of
_
below we can enumerate all the possible variants, since there shouldn't be many left: justPrepare
andInvalid
. This makes it more explicit, and also ensures that we never miss handlingPossiblyInvalid
. Actually, this comment isn't even pedantic but genuinely useful.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.
That's actually a nice catch! But there are the guards, so we would have to enumerate every variants there.
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.
Hmm, you're right. I'd still refactor it to move the ifs out of the guards. It's worth enumerating all the variants here.
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.
By moving the ifs into the branch, every branch would become
if ... else break
. Probably not worth doing. Another it-ain't-broke-don't-fix-it example lol.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 know, but it'd be really nice to enumerate all the variants here. Some extra verbosity seems worth it to maintain correctness.
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.
Are you really sure about this? Please don't...
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.
Hmm, I don't think it's too bad. I'm worried that someone in the future may add a
PossiblyInvalid
case and forget to update this spot, because the_
swallows it.Maybe a small helper macro would be less verbose and more clear, e.g.
Or would it just obscure this code more? cc @s0me0ne-unkn0wn for a second opinion.
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 get that from the beginning. That's why I think it's a very good catch! If you still think it's worth it after seeing the code, alright then~