Sha256: 639f95662e3129f8a6c820bdb71f4684c6aa326f465b0c6adb6fbfa0fc2a0ade

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# Error handling

## Wayfarer never swallows exceptions

* Wayfarer never swallows exceptions.
* Jobs with unhandled exceptions are not retried.

## Retrying or discarding failing jobs

Wayfarer relies on [Active Job's two error handling facilities](https://guides.rubyonrails.org/active_job_basics.html#exceptions).

* `retry_on` to retry jobs a number of times on certain errors:

    ```ruby
    class DummyJob < Wayfarer::Base
      retry_on MyError, attempts: 3 do |job, error|
        # This block runs once all 3 attempts have failed
        # (1 initial attempt + 2 retries)

        raise error
      end
    end
    ```

* `discard_on` to throw away jobs on certain errors:

    ```ruby
    class DummyJob < Wayfarer::Base
      discard_on MyError do |job, error|
        # This block runs once and buries the job

        raise error
      end
    end
    ```

!!! attention "Always re-raise errors"

    You should always re-raise errors from `retry_on` and `discard_on` blocks,
    otherwise jobs will not get retried!

## Renewing agents on certain errors

```ruby
Wayfarer.config.network.renew_on = [MyError]
```

For example, if you use the Capybara
[Cuprite](https://github.com/rubycdp/cuprite) driver:

```ruby
Wayfarer.config.network.renew_on = [Ferrum::DeadBrowserError]
```

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wayfarer-0.4.6 docs/guides/error_handling.md