Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Debug] Support any Throwable object in FlattenException#26528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -15,7 +15,7 @@ | ||
| use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; | ||
| /** | ||
| * FlattenException wraps a PHPError orException to be able to serialize it. | ||
| * | ||
| * Basically, this class removes all objects from the trace. | ||
| * | ||
| @@ -34,6 +34,11 @@ class FlattenException | ||
| private $line; | ||
| public static function create(\Exception $exception, $statusCode = null, array $headers = array()) | ||
| { | ||
| return static::createFromThrowable($exception, $statusCode, $headers); | ||
| } | ||
| public static function createFromThrowable(\Throwable $exception, ?int $statusCode = null, array $headers = array()): self | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. What about using Member
| ||
| { | ||
| $e = new static(); | ||
| $e->setMessage($exception->getMessage()); | ||
| @@ -52,17 +57,15 @@ public static function create(\Exception $exception, $statusCode = null, array $ | ||
| $e->setStatusCode($statusCode); | ||
| $e->setHeaders($headers); | ||
| $e->setTraceFromThrowable($exception); | ||
| $e->setClass($exception instanceof FatalThrowableError ? $exception->getOriginalClassName() : \get_class($exception)); | ||
| $e->setFile($exception->getFile()); | ||
| $e->setLine($exception->getLine()); | ||
| $previous = $exception->getPrevious(); | ||
| if ($previous instanceof \Throwable) { | ||
| $e->setPrevious(static::createFromThrowable($previous)); | ||
| } | ||
| return $e; | ||
| @@ -178,9 +181,19 @@ public function getTrace() | ||
| return $this->trace; | ||
| } | ||
| /** | ||
| * @deprecated since 4.1, use {@see setTraceFromThrowable()} instead. | ||
| */ | ||
| public function setTraceFromException(\Exception $exception) | ||
| { | ||
| @trigger_error(sprintf('"%s" is deprecated since Symfony 4.1, use "setTraceFromThrowable()" instead.', __METHOD__), E_USER_DEPRECATED); | ||
| $this->setTraceFromThrowable($exception); | ||
| } | ||
| public function setTraceFromThrowable(\Throwable $throwable): void | ||
| { | ||
| $this->setTrace($throwable->getTrace(), $throwable->getFile(), $throwable->getLine()); | ||
| } | ||
| public function setTrace($trace, $file, $line) | ||