mirror of
https://github.com/flarum/framework.git
synced 2025-02-11 20:45:33 +08:00
improve queue error handling
This commit is contained in:
parent
62e1a8e5c2
commit
2febb2653f
|
@ -67,6 +67,7 @@ class Server
|
||||||
|
|
||||||
$error = $registry->handle($event->getError());
|
$error = $registry->handle($event->getError());
|
||||||
|
|
||||||
|
/** @var Reporter[] $reporters */
|
||||||
$reporters = $app->tagged(Reporter::class);
|
$reporters = $app->tagged(Reporter::class);
|
||||||
|
|
||||||
if ($error->shouldBeReported()) {
|
if ($error->shouldBeReported()) {
|
||||||
|
|
|
@ -13,11 +13,14 @@ namespace Flarum\Queue;
|
||||||
|
|
||||||
use Flarum\Console\Event\Configuring;
|
use Flarum\Console\Event\Configuring;
|
||||||
use Flarum\Foundation\AbstractServiceProvider;
|
use Flarum\Foundation\AbstractServiceProvider;
|
||||||
|
use Flarum\Foundation\ErrorHandling\Registry;
|
||||||
|
use Flarum\Foundation\ErrorHandling\Reporter;
|
||||||
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandling;
|
use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandling;
|
||||||
use Illuminate\Contracts\Queue\Factory;
|
use Illuminate\Contracts\Queue\Factory;
|
||||||
use Illuminate\Contracts\Queue\Queue;
|
use Illuminate\Contracts\Queue\Queue;
|
||||||
use Illuminate\Queue\Connectors\ConnectorInterface;
|
use Illuminate\Queue\Connectors\ConnectorInterface;
|
||||||
use Illuminate\Queue\Console as Commands;
|
use Illuminate\Queue\Console as Commands;
|
||||||
|
use Illuminate\Queue\Events\JobFailed;
|
||||||
use Illuminate\Queue\Failed\NullFailedJobProvider;
|
use Illuminate\Queue\Failed\NullFailedJobProvider;
|
||||||
use Illuminate\Queue\Listener as QueueListener;
|
use Illuminate\Queue\Listener as QueueListener;
|
||||||
use Illuminate\Queue\SyncQueue;
|
use Illuminate\Queue\SyncQueue;
|
||||||
|
@ -109,4 +112,23 @@ class QueueServiceProvider extends AbstractServiceProvider
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->app['events']->listen(JobFailed::class, function (JobFailed $event) {
|
||||||
|
/** @var Registry $registry */
|
||||||
|
$registry = $this->app->make(Registry::class);
|
||||||
|
|
||||||
|
$error = $registry->handle($event->exception);
|
||||||
|
|
||||||
|
/** @var Reporter[] $reporters */
|
||||||
|
$reporters = $this->app->tagged(Reporter::class);
|
||||||
|
|
||||||
|
if ($error->shouldBeReported()) {
|
||||||
|
foreach ($reporters as $reporter) {
|
||||||
|
$reporter->report($error->getException());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user