Skip to content

Cannot define custom handle_errors callback #36

@TylerPachal

Description

@TylerPachal

I have a Phoenix project and in my router.ex file I tried to define a handle_errors/2 callback as defined in the docs, so that I could change some errors I was handing back to users.

Unfortunately this did not work because the handle_errors defined in Plugsnag are being inserted above my definition.

Example:

defmodule ApiWeb.Router do
  use Plug.Router
  use Plugsnag

  # Never gets triggered
  defp handle_errors(conn, %{kind: _kind, reason: _reason, stack: _stack}) do
    send_resp(conn, conn.status, "Something went wrong")
  end
end

I believe that the handle_errors/2 definitions need to be moved from __using__ into a new __before_compile__ block, so that definitions in the application router will be inserted above those in Plugsnag macro.

I can prepare the change if this repo is still active.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions