Skip to content
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 multiple catch blocks #1075

Closed
StefanKarpinski opened this issue Jul 21, 2012 · 4 comments
Closed

allow multiple catch blocks #1075

StefanKarpinski opened this issue Jul 21, 2012 · 4 comments
Assignees

Comments

@StefanKarpinski
Copy link
Member

One ought to be able to write something like this:

try f()
catch e::NoMethodError
  # handle no method error
catch e::SomeOtherError
  # handle some other error
catch e
  # handle any thrown object
end

Although it needn't actually be implemented by creating a generic function, this should probably emulate the behavior of dispatch, implying that clause order doesn't matter.

@ghost ghost assigned JeffBezanson Jul 21, 2012
@JeffBezanson
Copy link
Member

I assume the semantics are that if none of the catch clauses match, the handler is skipped and we go to the next one down the stack?

@StefanKarpinski
Copy link
Member Author

Yes, exactly.

@ViralBShah
Copy link
Member

I like this and it fits the multiple dispatch style of programming nicely.

@JeffBezanson
Copy link
Member

Can now be done with if and rethrow. We also decided that catching exceptions by type does not really make sense. You either catch all exceptions (and possibly rethrow), or unwind to a specific handler by label (to be implemented later).

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

No branches or pull requests

3 participants