本文整理汇总了PHP中Exception::getErrorType方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getErrorType方法的具体用法?PHP Exception::getErrorType怎么用?PHP Exception::getErrorType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getErrorType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setErrorResponse
/**
* Create an error response for any exception thrown while creating this email
*
* @param \Exception $e
*
*/
protected function setErrorResponse(\Exception $e)
{
if ($e instanceof ControllerException) {
$result = $e->getErrorType();
} else {
$result = 'genericError';
}
WikiaLogger::instance()->error('Error while sending email', ['result' => $result, 'msg' => $e->getMessage()]);
$this->hasErrorResponse = true;
$this->response->setData(['result' => $result, 'msg' => $e->getMessage()]);
}
示例2: handleException
/**
* {@inheritDoc}
*/
public function handleException(\Exception $e)
{
$refl = new \ReflectionClass($e);
if ($e instanceof HttpExceptionInterface) {
$title = sprintf('%s::%s', $refl->getShortName(), $e->getErrorType());
$detail = $e->getMessage();
$status = $e->getHttpCode();
} else {
$title = $refl->getShortName();
$detail = 'Oh no! Something bad happened on the server! Please try again.';
$status = 500;
}
$serialized = $this->getSerializer()->serializeError($title, $detail, $status);
$payload = new Rest\RestPayload($serialized);
return $this->createRestResponse($status, $payload);
}