Details
-
Feature Request
-
Resolution: Done
-
Major
-
None
-
None
-
None
Description
It would be very helpful to be able to inject code upon method throwing an exception, or code executed regardless of the way the control flow returns from the function.
In order to be backwards compatible I'd suggest location specifiers
AT EXIT THROWING [exception type, defaults to Throwable] = try { /* method body */ } catch ( /* exception type */ $!) { /* rule contents */ throw $!; } AT EXIT FINALLY = try { /* method body */ } finally { /* rule contents */ throw $!; } AFTER INVOKE (regular AFTER INVOKE args) THROWING [exception type, defaults to Throwable] = try { /* method invocation */ } catch ( /* exception type */ $!) { /* rule contents */ throw $!; } AFTER INVOKE (regular AFTER INVOKE args) FINALLY = try { /* method invocation */ } finally { /* rule contents */ throw $!; }
Are there any caveats with this? The latter two should obviously introduce some local variable where the return value would be temporarily stored...