Yar_Server_Exception::getType
PHP Manual
PHP Manual»Yar_Server_Exception»Yar_Server_Exception::getType

Yar_Server_Exception::getType

(PECL yar >= 1.0.0)

Yar_Server_Exception::getType — Retrieve exception's type

Açıklama

public function Yar_Server_Exception::getType(): string|int

When a remote method throws an exception, the server embeds the original exception in the response and the client re-throws it as a Yar_Server_Exception. This method returns the class name of that original exception.

Bağımsız Değişkenler

Bu işlevin bağımsız değişkeni yoktur.

Dönen Değerler

The class name of the exception thrown by the remote service, or "Yar_Exception_Server" when the server-side exception carried no class name.

Örnekler

Örnek 1 Yar_Server_Exception::getType() example

<?php
/* Server.php */
class Custom_Exception extends Exception {};

class API {
    public function throw_exception($name) {
        throw new Custom_Exception($name);
    }
}

$service = new Yar_Server(new API());
$service->handle();
?>
<?php
/* Client.php */
$client = new Yar_Client("http://api.example.com/operator.php");

try {
    $client->throw_exception("client");
} catch (Yar_Server_Exception $e) {
    var_dump($e->getType());
    var_dump($e->getMessage());
}
?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

string(16) "Custom_Exception"
string(6) "client"

Ayrıca Bakınız

To Top