Skip to content
Kevin Disneur edited this page Feb 27, 2017 · 1 revision

Examples

  1. How to catch specific errors?

The specific error tuple containing the error is stored inside the Bamboo.SMTPAdapter.SMTPError structure. You could access it this way:

def send_an_email(email) do
  try do
    MyApp.Mailer.deliver_now(email)
  rescue
    error in Bamboo.SMTPAdapter.SMTPError ->
      case error.raw do
        {:retries_exceeded, _} ->
          IO.inspect("I can do some stuff when this error match")
        _ ->
          IO.inspect "I don't care about these ones"
      end
      # Here, I can re-raise the error
      raise error
  end
end
Clone this wiki locally