Skip to content

Commit

Permalink
Merge pull request #632 from rollbar/fixed/issue-631-message-in-descr…
Browse files Browse the repository at this point in the history
…iption

Fixed #631 Set log message as primary
  • Loading branch information
danielmorell authored Dec 22, 2023
2 parents a69b14a + 59e0360 commit 72fc135
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions src/DataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,25 @@ public function makeTrace(
?string $classOverride = null,
string|Stringable $message = null,
): Trace {
$frames = array();
if ($this->captureErrorStacktraces) {
$frames = $this->makeFrames($exception, $includeContext);
} else {
$frames = array();
}

$exceptionMessage = $exception->getMessage();
$description = $message;

// If a message is explicitly set when calling the logger, use that. Otherwise, use the exception's message.
if (null !== $message) {
$exceptionMessage = $message;
$description = $exception->getMessage();
}

$excInfo = new ExceptionInfo(
return new Trace($frames, new ExceptionInfo(
$classOverride ?: get_class($exception),
$exception->getMessage(),
$message
);
return new Trace($frames, $excInfo);
$exceptionMessage,
$description,
));
}

public function makeFrames($exception, $includeContext)
Expand Down
4 changes: 2 additions & 2 deletions tests/DataBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ public function testExceptionInContext(): void
$this->assertSame(
array(
'class' => 'Exception',
'message' => 'testing exception',
'description' => 'testing',
'message' => 'testing',
'description' => 'testing exception',
),
$output['body']['trace']['exception'],
);
Expand Down

0 comments on commit 72fc135

Please sign in to comment.