From 72fe2ccea8781b683373b2d918c0e84265ec9633 Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Sun, 5 Mar 2023 15:52:08 -0600 Subject: [PATCH] Include context backtrace in message --- src/Context/Internal/ContextException.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Context/Internal/ContextException.php b/src/Context/Internal/ContextException.php index e7c23db..7d0b53c 100644 --- a/src/Context/Internal/ContextException.php +++ b/src/Context/Internal/ContextException.php @@ -26,9 +26,7 @@ public function __construct( ?\Throwable $previous = null, ) { $format = '%s thrown in context with message "%s" and code "%s" in %s:%d' - . '; call %s::getOriginalTrace() for the stack trace in the context as an array;' - . ' if the Xdebug extension is enabled, set "xdebug.mode" to "debug" to include' - . ' the exception stack trace in the context in the exception message'; + . "\nStack trace in context:\n%s" ; parent::__construct(\sprintf( $format, @@ -37,15 +35,10 @@ public function __construct( $originalCode, $originalFile, $originalLine, - self::class, + $this->getOriginalTraceAsString(), ), previous: $previous); } - public function __toString(): string - { - return \sprintf("%s\nStack trace in context:\n%s", $this->getMessage(), $this->getOriginalTraceAsString()); - } - /** * @return class-string<\Throwable> Original exception class name. */