Coder Social home page Coder Social logo

catch error about bamboo_smtp HOT 6 CLOSED

fewlinesco avatar fewlinesco commented on June 30, 2024
catch error

from bamboo_smtp.

Comments (6)

kdisneur avatar kdisneur commented on June 30, 2024

Hello @benjamin79, do you think this commit could help you to fix your issue?

Basically you could match some specific errors 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

from bamboo_smtp.

benjamin79 avatar benjamin79 commented on June 30, 2024

Thank you, looks good. Will give it a try.

from bamboo_smtp.

kdisneur avatar kdisneur commented on June 30, 2024

Cool - Let us now if it works as you expect. If it is, we will release it.

from bamboo_smtp.

benjamin79 avatar benjamin79 commented on June 30, 2024

There is 1 end too much. It works - almost. For example if i set the wrong to i get the following in error:

%Bamboo.SMTPAdapter.SMTPError{message: "There was a problem sending the email through SMTP.\n\nThe error is :no_more_hosts\n\nMore detail below:\n\n{:permanent_failure, \"email-server", \"501 Invalid RCPT TO address provided\\r\\n\"}\n"}

So no error.raw. Iยดm using aws ses if it is important.

from bamboo_smtp.

kdisneur avatar kdisneur commented on June 30, 2024
  1. too much end: Thanks - I will fix the documentation.
  2. Are you sure to use the correct branch (i.e: feature/#50-catch_error)? The fix is not yet released, we wanted you to test the branch to be sure it works as you expect before creating a new release.

On the branch feature/#50-catch_error, the error should be:

%Bamboo.SMTPAdapter.SMTPError{
  raw: {:no_more_hosts, {:permanent_failure, \"email-server", \"501 Invalid RCPT TO address provided\\r\\n\"}},
  message: "There was a problem sending the email through SMTP.\n\nThe error is :no_more_hosts\n\nMore detail below:\n\n{:permanent_failure, \"email-server", \"501 Invalid RCPT TO address provided\\r\\n\"}\n"}

To use the branch feature/#50-catch_error, you need to update your mix.exs file to be:

defp deps do
  [ # some deps...
    {:bamboo_smtp, github: "fewlinesco/bamboo_smtp", branch: "feature/#50-catch_error"}
  ]
end

from bamboo_smtp.

benjamin79 avatar benjamin79 commented on June 30, 2024

Great, works. Thank you.

from bamboo_smtp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.