Honeybadger.Plug (Honeybadger v0.16.0) View Source

The Honeybadger.Plug adds automatic error handling to a plug pipeline.

Within a Plug.Router or Phoenix.Router use the module and crashes will be reported to Honeybadger. It's best to use Honeybadger.Plug after the Router plugs so that exceptions due to non-matching routes are not reported to Honeybadger.

Example

defmodule MyPhoenixApp.Router do
  use Crywolf.Web, :router
  use Honeybadger.Plug

  pipeline :browser do
    [...]
  end
end

Customizing

Data reporting may be customized by passing an alternate :plug_data module. This is useful when working with alternate frameworks, such as Absinthe for GraphQL APIs.

Any module with a metadata/2 function that accepts a Plug.Conn and a module name can be used to generate metadata.

Example

defmodule MyPhoenixApp.Router do
  use Crywolf.Web, :router
  use Honeybadger.Plug, plug_data: MyAbsinthePlugData
end