本文整理汇总了PHP中SplSubject::getException方法的典型用法代码示例。如果您正苦于以下问题:PHP SplSubject::getException方法的具体用法?PHP SplSubject::getException怎么用?PHP SplSubject::getException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplSubject
的用法示例。
在下文中一共展示了SplSubject::getException方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update(\SplSubject $subject, $isException = false)
{
if (!$isException) {
$error = $subject->getError();
$typeLog = $error->code == 'E_FATAL' ? 'fatal' : 'error';
Logger::getInstance()->{$typeLog}(ucfirst($error->type) . ' : ' . $error->message . ' in ' . $error->file . ' on line ' . $error->line, 'error');
} else {
$exception = $subject->getException();
Logger::getInstance()->fatal('Exception' . ' : "' . $exception->message . '" in ' . $exception->file . ' on line ' . $exception->line . ' with trace : ' . chr(10) . $exception->trace, 'error');
}
}
示例2: update
/**
* Mail the sysadmin with Exception information.
*
* @param SplSubject $subject The ExceptionHandler
* @return bool
*/
public function update(SplSubject $subject)
{
$exception = $subject->getException();
// perhaps emailer also would like to know the server in question
$output = 'Server: ' . $_SERVER['HOSTNAME'] . PHP_EOL;
$output .= 'File: ' . $exception->getFile() . PHP_EOL;
$output .= 'Line: ' . $exception->getLine() . PHP_EOL;
$output .= 'Message: ' . PHP_EOL . $exception->getMessage() . PHP_EOL;
$output .= 'Stack Trace:' . PHP_EOL . $exception->getTraceAsString() . PHP_EOL;
$headers = 'From: webmaster@yourdomain.com' . "\r\n" . 'Reply-To: webmaster@yourdomain.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
echo "\n\nThe following email (would be) sent to your webmaster@yourdomain.com:\n\n";
echo $output;
//return mail('webmaster@yourdomain.com', 'Exception Thrown', $output, $headers);
}
示例3: update
/**
* Update the error_log with
* information about the Exception.
*
* @param SplSubject $subject The ExceptionHandler
* @return boolean
*/
public function update(SplSubject $subject)
{
return error_log($subject->getException(), 0, $this->filename);
}