Skip to content

Commit d948660

Browse files
committed
Merge branch 'develop'
2 parents f58b26b + f2a952c commit d948660

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/ApiWriter/ApiWriter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ public function __construct(
3333

3434
public function exception(\Throwable $throwable): void
3535
{
36-
$json = $this->toArray($throwable);
36+
$json = $this->toArray($throwable, true);
3737
$json['caught'] = $throwable instanceof CaughtException;
3838
$this->process('exception', $json);
3939
}
4040

4141
public function deprecation(\Throwable $throwable): void
4242
{
43-
$json = $this->toArray($throwable);
43+
$json = $this->toArray($throwable, false);
4444
$this->process('deprecation', $json);
4545
}
4646

@@ -55,14 +55,14 @@ private function process(string $type, array $json): void
5555
/**
5656
* @return array<string, mixed>
5757
*/
58-
private function toArray(\Throwable $throwable): array
58+
private function toArray(\Throwable $throwable, bool $includeDetails): array
5959
{
6060
return [
6161
'file' => $throwable->getFile(),
6262
'line' => $throwable->getLine(),
6363
'user' => $this->renderer->getUserIdentifier(),
6464
'message' => $throwable->getMessage(),
65-
'contents' => $this->renderer->render($throwable),
65+
'contents' => $this->renderer->render($throwable, $includeDetails),
6666
];
6767
}
6868

src/ExceptionRenderer/ExceptionRenderer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public function __construct(private TokenStorageInterface $tokenStorage)
1515
{
1616
}
1717

18-
public function render(\Throwable $throwable): string
18+
public function render(\Throwable $throwable, bool $includeDetails): string
1919
{
2020
return $throwable->getMessage()."\n\n".
2121
$throwable->getTraceAsString()."\n\n".
22-
$this->formatBacktrace(debug_backtrace());
22+
$this->formatBacktrace(debug_backtrace(), $includeDetails);
2323
}
2424

2525
public function getUserIdentifier(): ?string
@@ -47,14 +47,16 @@ public function getUserIdentifier(): ?string
4747
/**
4848
* @param array<int, mixed[]> $backtrace
4949
*/
50-
private function formatBacktrace(array $backtrace): string
50+
private function formatBacktrace(array $backtrace, bool $includeDetails): string
5151
{
5252
$string = '';
5353

54-
if (PHP_SAPI !== 'cli') {
55-
$string .= "\nREQUEST DETAILS\n".$this->getRequestDetails();
56-
} else {
57-
$string .= "\nCOMMAND DETAILS\n".$this->getCommandDetails();
54+
if ($includeDetails) {
55+
if (PHP_SAPI !== 'cli') {
56+
$string .= "\nREQUEST DETAILS\n".$this->getRequestDetails();
57+
} else {
58+
$string .= "\nCOMMAND DETAILS\n".$this->getCommandDetails();
59+
}
5860
}
5961

6062
$string .= "\nFULL BACKTRACE\n";

0 commit comments

Comments
 (0)