Boo

Exception Handling: Allow for exception fault handlers

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 0.7.9
  • Fix Version/s: 0.8.1
  • Component/s: Compiler, Emitter, Parser
  • Labels:
    None
  • Number of attachments :
    0

Description

The CLI provides the ability similar to 'finally'. Whereas 'finally' runs whether or not a try block exits normally, the 'fault' block only runs if the 'try' block exits abnormally through an exception. Both finally and fault run prior to other handlers.

http://www.microsoft.com/mspress/books/sampchap/5771.aspx

Implementation Notes:
Only one fault handler per try block should be allowed.
A fault handler can appear with a finally handler.
When composed with finally, we should probably enforce that fault should appear first and run before finally.

I recommend taking over the obsolete keyword failure for this use.
Proposed syntax:

try:
  raise Exception()
except:
  print "Caught"
failure:
  print "Exception thrown"
ensure:
  print "Completed"

This should print:

Caught
Exception thrown
Completed

Issue Links

Activity

Hide
Marcus Griep added a comment -

Fixed ordering of catch/filter versus fault/finally handler. Catch/filter handlers execute before fault/finally handlers.

Show
Marcus Griep added a comment - Fixed ordering of catch/filter versus fault/finally handler. Catch/filter handlers execute before fault/finally handlers.
Hide
Marcus Griep added a comment -

Patch to fix in related issue.

Show
Marcus Griep added a comment - Patch to fix in related issue.
Hide
Marcus Griep added a comment -

See related issue for patch

Show
Marcus Griep added a comment - See related issue for patch
Hide
Marcus Griep added a comment -

Revision 2744

Show
Marcus Griep added a comment - Revision 2744

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: