2 ms·
I ran into this when writing an ANTLR parser. I wanted to throw specialized exceptions based on what went wrong in the parse, but these couldn't be checked exce
by scott_s 9y ago
I ran into this when writing an ANTLR parser. I wanted to throw specialized exceptions based on what went wrong in the parse, but these couldn't be checked exceptions for the above reason. So I had to derive them from RuntimeException, and then I wrapped the call to the parser so that it caught just this kind of exception, and re-threw it as a non-RuntimeException so that it was checked throughout the rest of the code. I think this is an ANTLR-idiom, which I found to be an odd quirk - but one that's unavoidable because of how ANTLR and Java are designed.