Skip to content

Instantly share code, notes, and snippets.

@moritz
Created June 7, 2012 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/2891025 to your computer and use it in GitHub Desktop.
Save moritz/2891025 to your computer and use it in GitHub Desktop.
Exceptions grant summary
<h1>Final Grant Report for Structured Error Messages</h1>
<p>After working for more than a year on my <a
href="http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html">grant
on exceptions</a>, I am now confident that I have done all that I have
promised, and can now close the grant.</p>
<h2>Deliverables</h2>
<p>A short summary of what I did for each deliverable follows</p>
<h3>D1: Specification</h3>
<p><a href="http://perlcabal.org/syn/S32/Exception.html">S32::Exception</a>
contains my work in this area.</a>. It provides information about the basic
exception types, the backtrace printer and how they interact with the rest
of Perl 6.</p>
<p>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.</p>
<p>Several <a
href="http://perlgeek.de/blog-en/perl-6/2012-localizing-exceptions.html">approaches
to localization and internationalization</a> are now within reach and only
wait for somebody to do it.</p>
<h3>D2: Error catalog, tests</h3>
<p>The error catalog is also in
<p><a href="http://perlcabal.org/syn/S32/Exception.html">S32::Exception</a>.
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.</p>
<p>Tests are in <a
href="https://github.com/perl6/roast/blob/master/S32-exceptions/misc.t">the
roast repository</a>. 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
<code>throws_like</code> to <code>Test::Util</code> which makes testing of
typed exceptions very easy.</p>
<h3>D3: Implementation, tests, documentation</h3>
<p>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.</p>
<p>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.</p>
<p>Documentation for <a
href="https://github.com/perl6/mu/blob/master/docs/exceptions.pod">compiler
writers</a> and <a
href="https://github.com/perl6/roast/blob/master/packages/Test/Util.pm#L177">test
authors</a> is available.</p>
<h2>Other Exceptions Progress</h2>
<p>I'd also like to mention that I did several things related to exceptions
which were not covered by this grant:</p>
<ul>
<li><a href="http://perlgeek.de/blog-en/perl-6/2011-02-exceptions.writeback">greatly improved backtrace printer</a></li>
<li>Many exceptions from within the compilation process (such as parse
errors, redeclarations etc.) are now typed.</li>
<li>I enabled typed exceptions thrown from C code, and as a proof of
concept I ported all user-visible exceptions in <a
href="https://github.com/rakudo/rakudo/blob/nom/src/ops/perl6.ops">perl6.ops</a>
to their intended types.</li>
<li><a href="https://github.com/rakudo/rakudo/commit/ecf355fa54492999de368a4ca1aed21a016470ec">Exceptions
from within the meta model</a> can now be caught in the "actions" part of
the compiler, augmented with line numbers and file name and re-thrown</li>
<li>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.</li>
</ul>
<h2>Acknowledgements</h2>
<p>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.</p>
<h2>References</h2>
<ul>
<li><a href="http://news.perlfoundation.org/2011/02/hague-grant-application-struct.html">Grant appliacation</a></li>
<li><a href="http://news.perlfoundation.org/2011/04/structured-error-message-grant.html">Grant acceptance</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/grant-report-errors-1.html">First report (April 2011)</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/grant-report-errors-2.html">Second report (May 2011)</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/grant-report-errors-3.html">Third report (August 2011)</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/grant-report-errors-4.html">Fourth report (December 2011)</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/2011-02-exceptions.html">Exceptions status update (February 2012)</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/2012-oslo-hackathon-report.html">Oslo Hackathon Day 1: Fixes to the backtrace printer</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/2012-grant-report-exceptions-may.html">Report May 2012</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/2012-grant-report-final-status-update.html">Final report (June 2012)</a></li>
<li><a href="http://perlgeek.de/blog-en/perl-6/2012-localizing-exceptions.html">Localization of Error Messages</a></li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment