Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Thanks for this! I updated my question with info about your answer! Commented Jan 3, 2009 at 21:48
  • It sounds like Mr. Hejlsberg is justifying Pokemon exception handling. One of the huge problems with the design of exceptions in Java and C# is that way too much information is encoded in the type of an exception, while information should should be stored in exception instances isn't available in any consistent way. Exceptions should propagate up the call stack until all of the abnormal conditions represented thereby have been resolved; unfortunately, the type of an exception--even if recognized--does little to indicate whether a situation is resolved. If an exception is unrecognized... Commented Mar 8, 2013 at 19:13
  • ...the situation is even worse. If code calls FetchData and it throws an exception of an unexpected type, it has no way of knowing whether that exception simply means that the data is unavailable (in which case the ability of code to get by without it would "resolve" it), or whether it means the CPU is on fire and the system should do a "safety shutdown" at first opportunity. It sounds like Mr. Hejlsberg is suggesting that code should assume the former; perhaps that's the best possible strategy given the existing exception hierarchies, but it seems icky nonetheless. Commented Mar 8, 2013 at 19:20
  • I agree that throws Exceptin is ridiculous, because almost anything can throw an exception, you should just assume this can happen. But when you specify exceptions like throws A,B,C, it's just an annotation, to me, it should be used like a Comment block. It's like saying, hey client of my function, here's a tip, maybe you want to deal with A,B,C, cause these errors are likely to happen when using me. If you add D in the future, it's not a big deal if it's not being dealt with, but it's like adding new documentation, Oh by the way, now it would also be useful to catch D. Commented Nov 1, 2014 at 0:12