-
-
Notifications
You must be signed in to change notification settings - Fork 707
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
Name argument if data conversion fails in std.getopt #10593
Name argument if data conversion fails in std.getopt #10593
Conversation
Thanks for your pull request, @burner! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
|
7735b46
to
6f6fd6e
Compare
@thewilsonator thank you |
Looks like this breaks |
dlang/phobos#10593 changes the thrown exception type from `ConvException` to `GetOptException` to provide more context on failed conversion.
During this months planning session it was decided that breaking user code that this PR does, as signalled by tsv-utils is not acceptable. I won't close, as the exception can be changed back. |
Well tsv-utils is somewhat abandoned, meaning it should maybe not be in the buildkit thing, also it only breaks a unit-test, and there is a PR to fix the very strong assumption in the unittest |
@rikkimax The right answer to this is to remove the abandoned package from BuildKite and merge this. |
Honestly, it would break some of my personal projects as well, since you need to catch |
I think this can be fixed to be a nicer message with the same exception type, right? |
Yes, throwing a ConvException instead of an GetOptException is possible, please feels wrong to me conceptionally. std.getopt throwing ConvException even though std.getopt has GetOptException. @LightBender @jmdavis maybe you guys should have a think about this in general. |
If we were designing it from scratch, then maybe using So, even if using a different exception type than we currently do would be desirable, we can't do so without breaking existing code (and in this case, the kind of code that's going to break likely won't be on code.dlang.org, because If we don't care about breaking that code, then we can make the change, but the decision on that in general is that we don't want to break existing code, often even when it arguably would be desirable to do so. Personally, I have code that would break with this change, and at least some of it actually gives more detailed information about what's required than can be given with an error message from Phobos, because it depends on what my program is doing, and for that to work, my program needs to know that the conversion failed, not just that As a general rule, if we don't want to break existing code, we cannot change exception types unless we change to subclasses, because existing code can catch those specific exception types and act according to what that type was. In that respect, changing Changing the exception type that a function throws is a lot like changing the return type except that you're probably not going to get a compilation error when you change to a type that wasn't a subclass of what was being thrown before. Instead, you're going to get behavioral changes that can't be caught by the compiler. And the logic for when you can change the exception type without breaking code is roughly the same as with a return type. Subclasses are generally fine, because they can be used by code that expected the original type, but changing to an unrelated type (or to a super type) breaks code. Similarly, adding new, unrelated exception types to be thrown can break code, because code that was written to handle all of the specific exception types that a function threw would then be missing one. So, in practice, we need to be about as careful with which exception types a function throws as we are with what it returns, and arguably, in this case, part of the problem is that we weren't careful enough with I have no problem with doing something different with Phobos v3's version of |
What about |
@burner will the solution that @schveiguy proposed work for you to resolve the bug? |
Fixes dlang#9662 whitespace
6f6fd6e
to
e73d06b
Compare
Yes, just pushed the change |
@jmdavis @LightBender maybe have a look here https://youtu.be/7R204VUlzGc?t=1708 I think there are some ideas to copy. |
I'm ok with the error messages from tsv-utils, they are exposing them directly to the user which is just bad form for a CLI tool. |
Do we need to remove tsv-utils from the BuildKite until they merge a fix? Because it looks like merging this will permanently break buildkite. @rikkimax @schveiguy |
I'm ok with disabling it at this point. Expecting exact text for error messages is a bit over the top. |
@LightBender you didn't disable the test? Merging it like this will break all other PRs. |
buildkite pr: dlang/ci#491 |
@schveiguy I thought I could do it after the merge and I was rummaging around for the build file when you sent your PR in. |
I dislike merging PRs with failing required runs, because it leads to confusing breakage. In this case, it's probably ok, because we know the breakage and will fix it. But for other PRs, they may have this stale state where buildkite is broken, and they are confused as to why it's not working, since it has nothing to do with their code. |
Fixes #9662
revival of #3491 as the suggested "better" solution never happened