Merge pull request #445 from filp/plain-text-in-pretty-page

Plain text in pretty page
This commit is contained in:
Denis Sokolov
2016-09-04 21:31:32 +03:00
committed by GitHub
3 changed files with 23 additions and 10 deletions
+17 -9
View File
@@ -128,6 +128,22 @@ class PlainTextHandler extends Handler
$this->traceFunctionArgsOutputLimit = (integer) $traceFunctionArgsOutputLimit;
}
/**
* Create plain text response and return it as a string
* @return string
*/
public function generateResponse()
{
$exception = $this->getException();
return sprintf("%s: %s in file %s on line %d%s\n",
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$this->getTraceOutput()
);
}
/**
* Get the size limit in bytes of frame arguments var_dump output.
* If the limit is reached, the var_dump output is discarded.
@@ -240,15 +256,7 @@ class PlainTextHandler extends Handler
*/
public function handle()
{
$exception = $this->getException();
$response = sprintf("%s: %s in file %s on line %d%s\n",
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$this->getTraceOutput()
);
$response = $this->generateResponse();
if ($this->getLogger()) {
$this->getLogger()->error($response);
+5
View File
@@ -210,6 +210,11 @@ class PrettyPageHandler extends Handler
header('Content-Type: text/html');
}
$plainTextHandler = new PlainTextHandler();
$plainTextHandler->setException($this->getException());
$plainTextHandler->setInspector($this->getInspector());
$vars["preface"] = "<!--\n\n\n" . $plainTextHandler->generateResponse() . "\n\n\n\n\n\n\n\n\n\n\n-->";
$helper->setVariables($vars);
$helper->render($templateFile);
+1 -1
View File
@@ -3,7 +3,7 @@
* Layout template file for Whoops's pretty error output.
*/
?>
<!DOCTYPE html>
<!DOCTYPE html><?php echo $preface; ?>
<html>
<head>
<meta charset="utf-8">