Skip to content

Commit

Permalink
Auto detect error in withError
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwalk authored Mar 13, 2024
1 parent 71e2d4c commit 851f57e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/RecordBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ public function withNote(?string $note): static
}


public function withError(?Throwable $exception, bool $isFinished = false): static
public function withError(?Throwable $exception, bool $isFinished = null): static
{
$this->record['finished'] ??= $isFinished ?? !isset($exception);

if (!$exception instanceof Throwable) {
return $this;
}
Expand All @@ -96,7 +98,6 @@ public function withError(?Throwable $exception, bool $isFinished = false): stat
$className = ucfirst($className);

$this->record['note'] = $className.': '.$exception->getMessage();
$this->record['finished'] ??= $isFinished;
return $this;
}

Expand Down

0 comments on commit 851f57e

Please sign in to comment.