diff --git a/src/RecordBuilder.php b/src/RecordBuilder.php index c9878dd..9acc3c5 100644 --- a/src/RecordBuilder.php +++ b/src/RecordBuilder.php @@ -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; } @@ -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; }