php8.5
Home/ Manual/ yaf / yaf_request_abstract/ Yaf_Request_Abstract::getException

Yaf_Request_Abstract::getException

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Retrieve the exception

Description

Yaf_Request_Abstract::getException(): Exception|null

Retrieve the exception caught during dispatching.

Parameters Parameters

Return Values

The Exception caught during dispatching, or null if none.

Examples

Yaf_Request_Abstract::getException example

php
<?php
// In the bootstrap, enable exception catching so that any exception
// thrown during dispatching is forwarded to the error action
Yaf_Dispatcher::getInstance()->catchException(true);

class ErrorController extends Yaf_Controller_Abstract
{
    public function errorAction($exception)
    {
        var_dump($this->getRequest()->getException() === $exception);
    }
}
?>

The above example will output something similar to:

output
bool(true)

See Also

  • Yaf_Dispatcher::catchException

Source: reference/yaf/yaf_request_abstract/getexception.xml · from the official PHP manual (php/doc-en)