Should masked exceptions be an error?
Rory McGuire
rjmcguire at gmail.com
Tue Nov 24 02:41:05 PST 2009
Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> Consider:
>
> try {
> ...
> } catch (Exception) {
> ...
> } catch (StdioException) {
> ...
> }
>
> The second handler never matches because StdioException is a subclass of
> Exception, so the first handler will always match whatever the second
> matches.
>
> Should that be a compile-time error? I think so.
>
>
> Andrei
>
Yes, I think so too.
And shouldn't the following also produce a compile-time error?
void main() {
try {
} catch (Exception e) {
}
}
More information about the Digitalmars-d
mailing list