Exceptions: Difference between revisions

389 bytes added ,  31 January 2008
new intro for new plan
No edit summary
(new intro for new plan)
Line 1: Line 1:
This is a discussion and planning document for refactoring [[Mozilla 2]] to use C++ exceptions. Briefly, this means:
This is a discussion and planning document for refactoring [[Mozilla]] to use C++ exceptions. Exceptions will likely arrive after Mozilla 2, but we hope to improve out-of-memory (OOM) handling for Mozilla 2 and maybe take a few steps closer to exception safety.


* Enabling exceptions in the compiler
Originally, this page suggested the goal would be to enable exceptions while preserving current behavior. But it looks like preserving current behavior exactly would make the code too ugly (e.g., needing try statements with empty catch blocks for ignored error codes), defeating the main purpose of going to exceptions. The new goal is to go more slowly, improving error handling functionality and cleaning up the code so it looks really nice once exceptions can be turned on.


* Replacing nsresult returns and checks with throw and catch statements
The next steps are:


* Changing getter methods to return their results directly (see [[outparamdel]]) instead of through pointer-typed parameters
* Remove all current OOM handling code


The goal is to do all this without changing the behavior of Firefox, thus not introducing bugs. A somewhat more ambitious goal is to then refactor Firefox methods to be exception-safe as well, which will help avoid future bugs and may even eliminate a few existing bugs.
* Rewrite call sites that ignore nsresults
 
* Rewrite call sites that use NS_SUCCEEDED
 
These steps are explained in more detail below. And by the way, we'd love to have community help with any of these.  
 
= Foo =


== Benefits of Exceptions ==
== Benefits of Exceptions ==
313

edits