title: How to send an exception to Sentry from Laravel Job only on final fail?
body: <h1>Configuration</h1>
  <p>I'm using Laravel 8 with <code>sentry/sentry-laravel</code> plugin.</p>
  <p>There is a Job that works just fine 99% of time. It retries N times in case of any problems due to:</p>
  <pre><code>public $backoff = 120;
  
  public function retryUntil()
  {
      return now()-&gt;addHours(6);
  }
  </code></pre>
  <p>And it simply calls some service:</p>
  <pre><code>public function handle()
  {
      // Service calls some external API
      $service-&gt;doSomeWork(...);
  }
  </code></pre>
  <p>Method <code>doSomeWork</code> sometimes throws an exception due to network problems, like <code>Curl error: Operation timed out after 15001 milliseconds with 0 bytes received</code>. This is fine due to automatic retries. In most cases next retry will succeed.</p>
  <h1>Problem</h1>
  <p>Every curl error is sent to Sentry. As an administrator I must check every alert, because this job is pretty important and I can't miss actually failed job. For example:</p>
  <ol>
  <li>There is some network problem that is not resolved for an hour.</li>
  <li>Application queues a Job</li>
  <li>Every 2 minutes application generates similar message to Sentry</li>
  <li>After network problems resolved job succeeds, so no attention required</li>
  <li>But we are seing dozens of errors, that <em>theoretically</em> could be ignored. But what if there an actual problem in that pile and I will miss it?</li>
  </ol>
  <h1>Question</h1>
  <p>How to make that only &quot;final&quot; job fail would send a message to Sentry? I mean after 6 hours of failed retries: only then I'd like to receive <strong>one</strong> alert.</p>
  <h1>What I tried</h1>
  <p>There is one workaround that kind of &quot;works&quot;. We can replace <code>Exception</code> with <code>SomeCustomException</code> and add it to <code>\App\Exceptions\Handler::$dontReport</code> array. In that case there are no &quot;intermediate&quot; messages sent to Sentry.</p>
  <p>But when job finally fails, Laravel sends standard <code>... job has been attempted too many times or run too long</code> message without details of <strong>actual error</strong>.</p>