Moritz has completed his grant and provided the following closing report.
Moritz Lenz writes:
After working for more than a year on my grant on exceptions, I am now confident that I have done all that I have promised, and can now close the grant.
A short summary of what I did for each deliverable follows
S32::Exception contains my work in this area. It provides information about the basic exception types, the backtrace printer and how they interact with the rest of Perl 6.
There are certainly still open design question in the general space of exceptions like, how do we indicate that an exception should or should not print its backtrace by default? There are ways to achieve this right now, but it's not as easy as it it should be for the end user. However those open questions are well outside the realm of this grant. I still plan to tackle them in due time.
Several approaches to localization and internationalization are now within reach and only wait for somebody to do it.
D2: Error catalog, tests
The error catalog is also in S32::Exception. It is not comprehensive (ie doesn't cover all possible errors that are thrown from current compilers), but the grant request only required an "initial" catalog. It is certainly enough to demonstrate the feasibility of the design, and to handle very many common cases.
Tests are in the roast repository. At the time of writing (2012-06-07) there are 424 tests, of which Rakudo passes nearly all (the few failures are due to known bugs not related to the exception subsystem). I added a utility test function
Test::Util which makes testing of typed exceptions very easy.
D3: Implementation, tests, documentation
Rakudo now throws only typed exceptions from its setting (with the exception of internal errors). Note that before my work started it only allowed strings as exceptions.
The tests mentioned above already cover several bug reports where people complained about wrong or less-than-awesome error messages. Since my main motivation was to make error testing more robust, I consider this a big success.
Other Exceptions Progress
I'd also like to mention that I did several things related to exceptions which were not covered by this grant:
- greatly improved backtrace printer
- Many exceptions from within the compilation process (such as parse errors, redeclarations etc.) are now typed.
- I enabled typed exceptions thrown from C code, and as a proof of concept I ported all user-visible exceptions in perl6.ops to their intended types.
- Exceptions from within the meta model can now be caught in the "actions" part of the compiler, augmented with line numbers and file name and re-thrown
- The Rakudo developers usually only close bug reports when tests are available. I wrote many tests for specific error conditions in response to such bug reports and closed the tickets.
I'd like to thank Ian Hague and the Perl Foundation for funding this grant, Karen Pauley and Will Coleda for managing it, and all the people who helped me designing, programming and wording things, especially Jonathan Worthington.