本文整理匯總了PHP中GuzzleHttp\Exception\RequestException::emittedError方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestException::emittedError方法的具體用法?PHP RequestException::emittedError怎麽用?PHP RequestException::emittedError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GuzzleHttp\Exception\RequestException
的用法示例。
在下文中一共展示了RequestException::emittedError方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: emitError
/**
* Emits an error event for a request and accounts for the propagation
* of an error event being stopped to prevent the exception from being
* thrown.
*
* @param TransactionInterface $transaction
* @param \Exception $e
* @param array $stats
*
* @throws \GuzzleHttp\Exception\RequestException
*/
public static function emitError(TransactionInterface $transaction, \Exception $e, array $stats = [])
{
$request = $transaction->getRequest();
// Convert non-request exception to a wrapped exception
if (!$e instanceof RequestException) {
$e = new RequestException($e->getMessage(), $request, null, $e);
}
// Mark the exception as having been emitted for an error event. This
// works in tandem with the emitBefore method to prevent the error
// event from being triggered twice for the same exception.
$e->emittedError(true);
// Dispatch an event and allow interception
if (!$request->getEmitter()->emit('error', new ErrorEvent($transaction, $e, $stats))->isPropagationStopped()) {
throw $e;
}
}