本文整理汇总了PHP中Exception::getJsonBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getJsonBody方法的具体用法?PHP Exception::getJsonBody怎么用?PHP Exception::getJsonBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getJsonBody方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logError
public function logError(Exception $e, Model_Transaction $tx)
{
$body = $e->getJsonBody();
$err = $body['error'];
$tx->txn_status = $err['type'];
$tx->error = $err['message'];
$tx->status = 'processed';
$tx->updated_at = date('Y-m-d H:i:s');
$this->di['db']->store($tx);
if ($this->di['config']['debug']) {
error_log(json_encode($e->getJsonBody()));
}
throw new Exception($tx->error);
}
示例2: exceptionHendler
/**
* Stripe Exception handler
*
* Function will check the exception is instance of Stripe_ERROR. If it is instance of Stripe_ERROR then
* function will chek the type. If type is card_error then it sets result to 80 and saves the message to rtrans
* reference. otherwise it sets to 85 other stripe issue. If exception is not stripe one set result to 90.
*
* @param Exception $e Exception object
* @param string $function function name to complete the logs.
* @return void
*/
private function exceptionHendler($e, $rtrans, $function)
{
$error = $e->getJsonBody()['error'];
if ($e instanceof Stripe_Error) {
if ($error['type'] == 'card_error') {
$rtrans->setResult('80');
$rtrans->setReference($error['message']);
} else {
$rtrans->setResult('85');
}
} else {
$rtrans->setResult('90');
}
$this->_log("[RTRANS: {$rtrans->getId()}] Stripe::{$function}() - result: exception: " . print_r($error, true));
}