changes
This commit is contained in:
21
vendor/spatie/flare-client-php/src/Flare.php
vendored
21
vendor/spatie/flare-client-php/src/Flare.php
vendored
@@ -40,7 +40,7 @@ class Flare
|
||||
|
||||
protected ContextProviderDetector $contextDetector;
|
||||
|
||||
protected $previousExceptionHandler = null;
|
||||
protected mixed $previousExceptionHandler = null;
|
||||
|
||||
/** @var null|callable */
|
||||
protected $previousErrorHandler = null;
|
||||
@@ -211,15 +211,16 @@ class Flare
|
||||
|
||||
public function registerExceptionHandler(): self
|
||||
{
|
||||
/** @phpstan-ignore-next-line */
|
||||
$this->previousExceptionHandler = set_exception_handler([$this, 'handleException']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function registerErrorHandler(): self
|
||||
public function registerErrorHandler(?int $errorLevels = null): self
|
||||
{
|
||||
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
|
||||
$this->previousErrorHandler = $errorLevels
|
||||
? set_error_handler([$this, 'handleError'], $errorLevels)
|
||||
: set_error_handler([$this, 'handleError']);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -309,7 +310,7 @@ class Flare
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function report(Throwable $throwable, callable $callback = null, Report $report = null): ?Report
|
||||
public function report(Throwable $throwable, callable $callback = null, Report $report = null, ?bool $handled = null): ?Report
|
||||
{
|
||||
if (! $this->shouldSendReport($throwable)) {
|
||||
return null;
|
||||
@@ -317,6 +318,10 @@ class Flare
|
||||
|
||||
$report ??= $this->createReport($throwable);
|
||||
|
||||
if ($handled) {
|
||||
$report->handled();
|
||||
}
|
||||
|
||||
if (! is_null($callback)) {
|
||||
call_user_func($callback, $report);
|
||||
}
|
||||
@@ -328,6 +333,11 @@ class Flare
|
||||
return $report;
|
||||
}
|
||||
|
||||
public function reportHandled(Throwable $throwable): ?Report
|
||||
{
|
||||
return $this->report($throwable, null, null, true);
|
||||
}
|
||||
|
||||
protected function shouldSendReport(Throwable $throwable): bool
|
||||
{
|
||||
if (isset($this->reportErrorLevels) && $throwable instanceof Error) {
|
||||
@@ -449,6 +459,7 @@ class Flare
|
||||
: $singleMiddleware;
|
||||
}, $this->middleware);
|
||||
|
||||
|
||||
$report = (new Pipeline())
|
||||
->send($report)
|
||||
->through($middleware)
|
||||
|
10
vendor/spatie/flare-client-php/src/Report.php
vendored
10
vendor/spatie/flare-client-php/src/Report.php
vendored
@@ -65,6 +65,8 @@ class Report
|
||||
|
||||
public static ?string $fakeTrackingUuid = null;
|
||||
|
||||
protected ?bool $handled = null;
|
||||
|
||||
/** @param array<class-string<ArgumentReducer>|ArgumentReducer>|ArgumentReducers|null $argumentReducers */
|
||||
public static function createForThrowable(
|
||||
Throwable $throwable,
|
||||
@@ -300,6 +302,13 @@ class Report
|
||||
return array_merge_recursive_distinct($context, $this->userProvidedContext);
|
||||
}
|
||||
|
||||
public function handled(?bool $handled = true): self
|
||||
{
|
||||
$this->handled = $handled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function exceptionContext(Throwable $throwable): self
|
||||
{
|
||||
if ($throwable instanceof ProvidesFlareContext) {
|
||||
@@ -376,6 +385,7 @@ class Report
|
||||
'application_path' => $this->applicationPath,
|
||||
'application_version' => $this->applicationVersion,
|
||||
'tracking_uuid' => $this->trackingUuid,
|
||||
'handled' => $this->handled,
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user