-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow type as argument to throwerrors #2
Conversation
test/runtests.jl
Outdated
# Invalid throwerrors values | ||
@test_throws DomainError iocapture(()->nothing, throwerrors=:foo) | ||
@test_throws TypeError iocapture(()->nothing, throwerrors=42) | ||
@test_throws DomainError iocapture(()->nothing, throwerrors=42) |
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 we bothered about this change at all?
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 would keep the test, but I wouldn't consider the exception type to be part of the public API, if that's what you mean.
src/IOCapture.jl
Outdated
# - `true` -> `Any`, | ||
# - `false` -> `Union{}`, | ||
# - `:interrupt` -> `InterruptException`. | ||
throwerrors = rewrite_error_argument(throwerrors) |
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.
Ain't terribly type-stable, but considering what else usually gets called in iocapture
I doubt it's of any concern.
eab1a1f
to
ca58ab0
Compare
Worth deprecating |
I would just get rid of |
src/IOCapture.jl
Outdated
Setting it to `Union{}` will capture all thrown exceptions and return them | ||
via the `.value` field, and will also set `.error` and `.backtrace` | ||
accordingly. Setting it to `false` also has this effect. | ||
|
||
To throw on a subset of possible exceptions pass the exception type instead, | ||
such as `InterruptException`. If multiple exception types may need to be | ||
thrown then pass a `Union{...}` of the types. Passing `:interrupt` has the | ||
same effect as using `InterruptException`. |
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 would emphasize here that the InterruptException
case is the one you usually want, e.g. by changing the order of the paragraphs.
ca58ab0
to
f763a24
Compare
f763a24
to
f18fb35
Compare
Either way is fine with me, shall I just drop them in this PR? |
If you don't mind then yeah 🙂 |
Also makes default |
I would argue against that, because while you probably shouldn't, you can
|
Not bothered either way :) Bit weird that it throws anything though, never come across that in any real code. |
28c384b
to
3d12c1f
Compare
LGTM, thanks a lot! |
Comments and docstrings probably need adjusting, I'll do that this afternoon if I have time.