Skip to content

Return DimensionMismatch rather than ErrorException #543

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

Merged
merged 1 commit into from
Nov 16, 2018
Merged

Conversation

timholy
Copy link
Member

@timholy timholy commented Nov 16, 2018

Seems reasonable to use the "official" exception type here. We don't seem to have a specific test for this (it's probably a @test_throws Exception ... test); I can make it more specific if desired.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 66.125% when pulling 4ac3e4e on teh/dm into a46d711 on master.

Copy link
Member

@andyferris andyferris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I’m notoriously bad at this, we should probably clean this up around the place.

@andyferris andyferris merged commit ceccb68 into master Nov 16, 2018
@timholy timholy deleted the teh/dm branch November 16, 2018 22:08
@timholy
Copy link
Member Author

timholy commented Nov 16, 2018

Want me to make the test more specific to lock this in place? Say the word and I'll do it.

Will want this tagged at some point for JuliaImages/ImageTransformations.jl#63

@andyferris
Copy link
Member

Yes - you’re of course very welcome to help out with this stuff! ;)

(To expand on my earlier response, I find that I often use return types in my code to handle the problems that I want to handle, and generally expect exceptions to exit. I’m frequently left with no idea what exception type to return because I can’t imagine the case I would catch these kinds of exceptions - ones like this tend to result from code bugs rather than input data, or interaction with live systems, or whatever).

@timholy
Copy link
Member Author

timholy commented Nov 17, 2018

95% of the time I use the exception type only for tests, to make sure it's failing the way I intend it to rather than for a far stupider reason. One of my greatest coding skilz is to introduce a typo in an error branch and getting a MethodError or UndefVarError while en route to what I hoped would throw a DimensionMismatch. Oops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants