Skip to content

Commit

Permalink
Include Exception with Laravel queue failures
Browse files Browse the repository at this point in the history
  • Loading branch information
awarrenlove committed Dec 10, 2021
1 parent 1e97698 commit 649924a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.idea
build
composer.lock
docs
vendor
coverage
.php-cs-fixer.cache
.phpunit.result.cache
2 changes: 1 addition & 1 deletion src/CallWebhookJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function handle()
if ($lastAttempt) {
$this->dispatchEvent(FinalWebhookCallFailedEvent::class);

$this->throwExceptionOnFailure ? $this->fail() : $this->delete();
$this->throwExceptionOnFailure ? $this->fail($exception) : $this->delete();
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion tests/CallWebhookJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Spatie\WebhookServer\Tests;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\TransferStats;
use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Event;
Expand Down Expand Up @@ -237,7 +238,11 @@ public function it_s_generate_job_failed_event_if_an_exception_throws_and_throw_

$this->artisan('queue:work --once');

Event::assertDispatched(JobFailed::class);
Event::assertDispatched(JobFailed::class, function (JobFailed $event) {
$this->assertInstanceOf(ConnectException::class, $event->exception);

return true;
});
}

protected function baseWebhook(): WebhookCall
Expand Down

0 comments on commit 649924a

Please sign in to comment.