dubbeltje
4 months ago

Injecting Bugsnag in queuefailed

Posted 4 months ago by dubbeltje

Hello,

I am trying to inject Bugsnag to Queue::failing in my AppServiceProvider as follows:

public function boot() {

Queue::failing(function (JobFailed $event, Bugsnag $bugsnag) {

            $payload = $event->job->payload();
            $jobName = $payload['displayName'];
            $bugsnag->notifyException($event->getException());

            
        });

}

This gives me the following Error:

2019-05-26 20:59:41] local.ERROR: Too few arguments to function ProjectScraper\Providers\AppServiceProvider::ProjectScraper\Providers\{closure}(), 1 passed in /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 347 and exactly 2 expected {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Too few arguments to function ProjectScraper\Providers\AppServiceProvider::ProjectScraper\Providers\{closure}(), 1 passed in /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 347 and exactly 2 expected at /home/vagrant/code/project/scraper/app/Providers/AppServiceProvider.php:38)
[stacktrace]
#0 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(347): ProjectScraper\Providers\AppServiceProvider->ProjectScraper\Providers\{closure}(Object(Illuminate\Queue\Events\JobFailed))
#1 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(196): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}('Illuminate\\Queu...', Array)
#2 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(185): Illuminate\Events\Dispatcher->dispatch('Illuminate\\Queu...')
#3 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/InteractsWithQueue.php(47): Illuminate\Queue\Jobs\Job->fail(Object(Exception))
#4 /home/vagrant/code/project/scraper/app/Jobs/Traits/UsesProxyCrawl.php(39): ProjectScraper\Jobs\FooScrapeJob->fail(Object(Exception))
#5 [internal function]: ProjectScraper\Jobs\FooScrapeJob->handle()
#6 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#7 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#9 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#10 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(94): Illuminate\Container\Container->call(Array)
#11 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(ProjectScraper\Jobs\FooScrapeJob))
#12 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(ProjectScraper\Jobs\FooScrapeJob))
#13 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#14 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(49): Illuminate\Bus\Dispatcher->dispatchNow(Object(ProjectScraper\Jobs\FooScrapeJob), false)
#15 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#16 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(327): Illuminate\Queue\Jobs\Job->fire()
#17 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(277): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), Object(Illuminate\Queue\WorkerOptions))
#18 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(118): Illuminate\Queue\Worker->runJob(Object(Illuminate\Queue\Jobs\RedisJob), 'redis', Object(Illuminate\Queue\WorkerOptions))
#19 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(102): Illuminate\Queue\Worker->daemon('redis', 'default', Object(Illuminate\Queue\WorkerOptions))
#20 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(86): Illuminate\Queue\Console\WorkCommand->runWorker('redis', 'default')
#21 [internal function]: Illuminate\Queue\Console\WorkCommand->handle()
#22 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array(Array, Array)
#23 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#24 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#25 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Container/Container.php(576): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#26 /home/vagrant/code/project/scraper/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)
#27 /home/vagrant/code/project/scraper/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#28 /home/vagrant/code/project/scraper/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))
#29 /home/vagrant/code/project/scraper/vendor/symfony/console/Application.php(908): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /home/vagrant/code/project/scraper/vendor/symfony/console/Application.php(269): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /home/vagrant/code/project/scraper/vendor/symfony/console/Application.php(145): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#32 /home/vagrant/code/project/scraper/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))
#33 /home/vagrant/code/project/scraper/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))
#34 /home/vagrant/code/project/scraper/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#35 {main}
"}

How could I fix this?

Please sign in or create an account to participate in this conversation.