PHP 8.6.0 Beta 3 is available for testing

Yaf_Exception::getPrevious

(Yaf >=1.0.0)

Yaf_Exception::getPreviousEl propósito de getPrevious

Descripción

public function Yaf_Exception::getPrevious(): Throwable

Este método se hereda de la jerarquía base de Throwable y devuelve la excepción encadenada como anterior, si la hay.

Parámetros

Esta función no contiene ningún parámetro.

Valores devueltos

Devuelve el previous Throwable if available, null en caso contrario.

Ejemplos

Ejemplo #1 Ejemplo de Yaf_Exception::getPrevious()

<?php
try {
    $previous = new RuntimeException("Failed to open view script", 1024);
    throw new Yaf_Exception(
        "Failed to dispatch the request",
        YAF_ERR_DISPATCH_FAILED,
        $previous
    );
} catch (Yaf_Exception $e) {
    var_dump($e->getCode());
    $prev = $e->getPrevious();
    var_dump(get_class($prev));
    var_dump($prev->getMessage());
    var_dump($prev->getCode());
}
?>

Resultado del ejemplo anterior es similar a:

int(514)
string(16) "RuntimeException"
string(26) "Failed to open view script"
int(1024)

Véase también

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top