-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Enhancement 7540 - Catch multiple exception types with single catch block #738
Conversation
|
fails autotester |
|
Conflicted with pull #737, should work now. |
| { | ||
| Type *t = (*types)[j]; | ||
| if (tn->implicitConvTo(t)) | ||
| error(loc, "%s is already covered by base class %s", tn->toChars(), t->toChars()); |
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.
tn and t could be the same. Maybe we could find a slightly better error message.
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.
Maybe "%s is listed more than once in catch list" or something. I don't like the normal wording much either. I hate coming up with error messages.
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.
How about the one from above. "catch of %s hides catch of %s" and "duplicate catch type %s".
|
Looks good to me. |
Supplemental changes of druntime/pull/72 - Issue 1824 - Object not const correct
|
Error messages improved. |
|
Do I understand this correctly? In your example, will |
|
@alexrp That's the idea. |
Allow catching multiple exceptions with 'catch(auto e : E1, E2, E3)' syntax. Expands TypeTuples in the type list.
|
I don't think I'm behind this. There's some loss of type information, and the syntax is "surprising". I'd think a better approach is to define a multi-catch as a template that avoids repetition of source code while still preserving full type information. Even that I'm not sure whether it's a big enough improvement. That being said, I recall another language (C#?) started supporting that recently. |
|
@andralex |
|
@yebblies Whatever the syntax, the block controlled by |
|
I'm going to drop this as I have no plans to fix/maintain it in the near future. |
Allow catching multiple exceptions with:
http://d.puremagic.com/issues/show_bug.cgi?id=7540