3.4.0
This commit is contained in:
@@ -46,6 +46,11 @@ class PlainTextHandler extends Handler
|
||||
*/
|
||||
private $traceFunctionArgsOutputLimit = 1024;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $addPreviousToOutput = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@@ -114,6 +119,21 @@ class PlainTextHandler extends Handler
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add previous exceptions to output.
|
||||
* @param bool|null $addPreviousToOutput
|
||||
* @return bool|$this
|
||||
*/
|
||||
public function addPreviousToOutput($addPreviousToOutput = null)
|
||||
{
|
||||
if (func_num_args() == 0) {
|
||||
return $this->addPreviousToOutput;
|
||||
}
|
||||
|
||||
$this->addPreviousToOutput = (bool) $addPreviousToOutput;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add error trace function arguments to output.
|
||||
* Set to True for all frame args, or integer for the n first frame args.
|
||||
@@ -151,14 +171,18 @@ class PlainTextHandler extends Handler
|
||||
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()
|
||||
);
|
||||
$message = $this->getExceptionOutput($exception);
|
||||
|
||||
if ($this->addPreviousToOutput) {
|
||||
$previous = $exception->getPrevious();
|
||||
while ($previous) {
|
||||
$message .= "\n\nCaused by\n" . $this->getExceptionOutput($previous);
|
||||
$previous = $previous->getPrevious();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $message . $this->getTraceOutput() . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,6 +308,22 @@ class PlainTextHandler extends Handler
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the exception as plain text.
|
||||
* @param \Throwable $exception
|
||||
* @return string
|
||||
*/
|
||||
private function getExceptionOutput($exception)
|
||||
{
|
||||
return sprintf(
|
||||
"%s: %s in file %s on line %d",
|
||||
get_class($exception),
|
||||
$exception->getMessage(),
|
||||
$exception->getFile(),
|
||||
$exception->getLine()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
Reference in New Issue
Block a user