(PECL yar >= 1.0.0)
Yar_Server_Exception::getType — 获取异常的类型
当远程方法抛出异常时,服务器会把原始异常嵌入响应中, 客户端会将其作为 Yar_Server_Exception 重新抛出。 此方法返回该原始异常的类名。
此函数没有参数。
远程服务抛出的异常的类名;如果服务器端的异常不携带类名,
则返回 "Yar_Exception_Server"。
示例 #1 Yar_Server_Exception::getType() 示例
<?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());
}
?>以上示例的输出类似于:
string(16) "Custom_Exception" string(6) "client"