本文整理汇总了PHP中Exception::getRawMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::getRawMessage方法的具体用法?PHP Exception::getRawMessage怎么用?PHP Exception::getRawMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::getRawMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleException
/**
* Handles a thrown exception. Will also log extra information if the exception happens to by a MySql deadlock.
*
* @param \Exception $exception The exception captured.
*
* @return null
*/
protected function handleException($exception)
{
// Do some logging.
if ($exception instanceof \HttpException) {
$status = $exception->status ? $exception->{$status} : '';
Craft::log(($status ? $status . ' - ' : '') . $exception->getMessage(), LogLevel::Warning);
} else {
if ($exception instanceof \Twig_Error) {
Craft::log($exception->getRawMessage(), LogLevel::Error);
} else {
Craft::log($exception->getMessage(), LogLevel::Error);
}
}
// Log MySQL deadlocks
if ($exception instanceof \CDbException && strpos($exception->getMessage(), 'Deadlock') !== false) {
$data = craft()->db->createCommand('SHOW ENGINE INNODB STATUS')->query();
$info = $data->read();
$info = serialize($info);
Craft::log('Deadlock error, innodb status: ' . $info, LogLevel::Error, 'system.db.CDbCommand');
}
// If this is a Twig Runtime exception, use the previous one instead
if ($exception instanceof \Twig_Error_Runtime) {
if ($previousException = $exception->getPrevious()) {
$exception = $previousException;
}
}
// Special handling for Twig syntax errors
if ($exception instanceof \Twig_Error) {
$this->handleTwigError($exception);
} else {
if ($exception instanceof DbConnectException) {
$this->handleDbConnectionError($exception);
} else {
parent::handleException($exception);
}
}
}
示例2: handleException
/**
* The __toString method isn't allowed to throw exceptions so we turn them into an error instead
*
* @param \Exception $e
*
* @return string
*/
private function handleException(\Exception $e)
{
trigger_error($e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_WARNING);
if ($e instanceof \Twig_Error) {
return '<strong>' . $e->getRawMessage() . '</strong>';
}
return '';
}