thekid/rfc — Issue #97: RFC 0097: TargetInvocationException
Author: thekid
Created: 2011-10-09 15:02:45+00:00
State: open
Labels: implemented, rfc

Scope of Change
====
lang.reflect.Routine will be changed to rethrow any exception as
TargetInvocationException (which is a chained exception).

Rationale
====
Get rid of another case where catch-all is needed.

Functionality
====

```php
getMethod('doSelect')->invoke($class->newInstance(), $args);
} catch (TargetInvocationException $e) {
Console::writeLine($m->getName(), ' invocation failed, cause: ', $e->cause->toString());
}
?>
```

Security considerations
====
n/a

Speed impact
====
Slightly slower

Dependencies
====
- New class lang.reflect.TargetInvocationException

Related documents
====
- http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/InvocationTargetException.html
Java calls this "InvocationTargetException"

- http://msdn2.microsoft.com/en-us/library/a89hcwhh.aspx
.NET MethodBase.Invoke()

- http://msdn2.microsoft.com/en-us/library/system.reflection.targetinvocationexception.aspx
.NET calls this "TargetInvocationException"

Comments
====
- friebe, Mon Jan 8 19:28:42 2007
Maybe InvocationException (withoud "Method") would be better?

- friebe, Wed May 30 15:09:01 2007
Staying with MethodInvocationException, InvocationException is already
a class in the remote package.

- friebe, Wed May 30 15:11:05 2007
This exception would be a ChainedException (cause member) but this
class is in the "util" package - thus this RFC would introduce a
lang -> util dependency... maybe ChainedException should be part of
"lang"?

- kiesel, Sun Jul 15 17:21:31 2007
ChainedException is used in so many places, that I think making
it a part of the lang package (and thus even more "core" than in
util package) is a good idea.

- friebe, Mon Aug 27 19:22:15 2007
lang.reflect.TargetInvocationException -> lang.ChainedException