Stephen Weeks wrote:
ExceptionHandler currently has a can_handle method that checks whether
the EH has been disabled or not.  I propose adding some attributes to
store the minimum severity the EH will handle and the list of exception
types the EH will handle, methods to set and get these properties, and
extend can_handle to check the exception against these properties.

Yes, this was spec'd but not yet implemented, and can be implemented now. ('can_handle' was intended to be expanded for this.)

Once this is in place, I understand we can remove the "disable exception
handler" functionality currently in place and replace it with setting
handled types appropriately.

Yes, once we have the ability to have exception handlers only handle specific types of exceptions, then they'll allow all other types of exceptions to pass through. (Which means we won't end up with the infinite exception handler loops we currently get if exception handlers aren't disabled as soon as they're used.)

Questions that have been raised about this proposal on IRC include:

* Minimum severity, range of severities, list of severities?

Minimum and maximum (which define a range if both are set). Let's skip selective lists ("I'll handle severity 2, 8, and 42" is less useful).

* List of types, or single type?
    - Note that you could create multiple EHs that refer to the same
      label or sub that handle different exception types.

A list of types. Ultimately exception types will likely be more than just integer types, but the integer types will do for now.


Also, the 'can_handle' method can be overloaded to check *any* attribute of the exception to decide if that handler can handle it. We may want to canonize this by allowing Parrot's ExceptionHandler PMC to store a sub object that is run by 'can_handle' on the exception to determine if it's appropriate.

Any proposals on naming or other API considerations?

The 'can_handle' method is the only required interface for checking whether a particular handler will accept a particular exception. All other checks should be hidden behind that method.

Any other thoughts or comments?

Make it so, Mr. Crusher. :)

Allison

Reply via email to