当我在laravel5.8上使用函数队列时,我想听一个事件 Queue :: exceptionOccurred
所以我在App\Providers\AppServiceProvider
上注册了它
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//exceptionOccurred
Queue::exceptionOccurred(function (JobFailed $event) {
Log::info('exception occurred',[
$event->connectionName,
$event->job,
$event->exception]);
});
}
然后,当我触发该事件时,我得到一些异常:
[2019-12-15 10:15:38] local.ERROR: Argument 1 passed to App\Providers\AppServiceProvider::App\Providers\{closure}() must be an instance of Illuminate\Queue\Events\JobFailed, instance of Illuminate\Queue\Events\JobExceptionOccurred given, called in /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 347 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Argument 1 passed to App\\Providers\\AppServiceProvider::App\\Providers\\{closure}() must be an instance of Illuminate\\Queue\\Events\\JobFailed, instance of Illuminate\\Queue\\Events\\JobExceptionOccurred given, called in /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 347 at /Users/jinmi/www/php/laravel_test/app/Providers/AppServiceProvider.php:38)
[stacktrace]
#0 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(347): App\\Providers\\AppServiceProvider->App\\Providers\\{closure}(Object(Illuminate\\Queue\\Events\\JobExceptionOccurred))
#1 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(196): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Queu...', Array)
#2 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(493): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Queu...')
#3 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(373): Illuminate\\Queue\\Worker->raiseExceptionOccurredJobEvent('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(ErrorException))
#4 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(341): Illuminate\\Queue\\Worker->handleJobException('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions), Object(ErrorException))
#5 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(283): Illuminate\\Queue\\Worker->process('database', Object(Illuminate\\Queue\\Jobs\\DatabaseJob), Object(Illuminate\\Queue\\WorkerOptions))
#6 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\\Queue\\Worker->runJob(Object(Illuminate\\Queue\\Jobs\\DatabaseJob), 'database', Object(Illuminate\\Queue\\WorkerOptions))
#7 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\\Queue\\Worker->daemon('database', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#8 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\\Queue\\Console\\WorkCommand->runWorker('database', 'default')
#9 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#10 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#11 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#12 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#13 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#14 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array)
#15 /Users/jinmi/www/php/laravel_test/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#16 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#17 /Users/jinmi/www/php/laravel_test/vendor/symfony/console/Application.php(915): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#18 /Users/jinmi/www/php/laravel_test/vendor/symfony/console/Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#19 /Users/jinmi/www/php/laravel_test/vendor/symfony/console/Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#20 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Console/Application.php(90): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#21 /Users/jinmi/www/php/laravel_test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(133): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /Users/jinmi/www/php/laravel_test/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 {main}
"}
我应该在这个项目上设置一些东西来解决此异常吗?
答案 0 :(得分:0)
像这样更改
WARNING: The pwd variable is not set. Defaulting to a blank string.