innerException in php
Wed Oct 28 2009
Zend engine actually does have support for innerException
This concept of inner Exception is unusual for someone who programmes
only in PHP, but in reality the inner Exception is a very common concept in
other languages like java, .NET, C# and probably
some others.
Most php classes don't use this little-known property
'innterException', that's why when people see an error or exception that
mentiones the innerException, they are very surprised, like 'WTF is
inner Exception'?
But you can just think of innerException as an exception object which
is a property of your caught exception object. So if you catch the
exception $e, you can check if it has property named
innerException. For example if(isset($e->innerException))
Then access the $e->innerException as any other exception object.
You can access the message, line number, etc. For example:
$e->innerException->getMessage();
$e->innerException->getLine();
Since Zend Engine 2 has a built-in support for innerException, the
custom php extensions can (and some do) make use of it. If a custom
php extension is written by a programmer who came from
C# or Java or .NET background, then the programmer may add
innerExceptions anywhere in his program and you - php developer should not
be surprised if you see them appear in your error log.
One such php extension that makes use of innerException concept is
HttpRequest, which is a very powerful php extension for generating http
requests and parsing responces.