Code Monkey home page Code Monkey logo

Comments (12)

renz45 avatar renz45 commented on September 15, 2024

Hi Jony,
I don't do anything specific to handle errors from the api in this gem, I just let them fall through from the mandrill-api gem that gets used to make the actual calls. Upon further investigation, it looks like the mandrill api itself doesn't care if the template exists or not. If/when they ever add this error check in, it should come back down the line.

An alternative I can see is to use the templates api to pull down a list of templates and check that against the template being used before making the call. Seems like an extra call may not be worth it unless there was a specific use case that justifies it.

I'm going to close this since it's more of an issue on Mandrill's side I think, feel free to re-open if you find otherwise. :)

from mandrill_mailer.

jonyt avatar jonyt commented on September 15, 2024

hi Adam,

I checked it on bare Mandrill API with the code below. It does seem to raise an exception if the template doesn't exist.

require 'mandrill'
begin
    mandrill = Mandrill::API.new 'MY_KEY'
    template_name = "non-existent"
    template_content = [{"SOMEVAR"=>"123"}]
    message = {
      'to' => [{'email' => '[email protected]'}]
    }
    result = mandrill.messages.send_template template_name, template_content, message
rescue Mandrill::Error => e
    # Mandrill errors are thrown as exceptions
    puts "A mandrill error occurred: #{e.class} - #{e.message}"
    raise
end

from mandrill_mailer.

renz45 avatar renz45 commented on September 15, 2024

Interesting.. using their api example runner, I wasn't seeing any errors. This gem pretty much does what your above code does and calls the api directly: https://github.com/renz45/mandrill_mailer/blob/master/lib/mandrill_mailer/template_mailer.rb#L116

What version of the api gem are you using to run that above code? I'm wondering if a newer version does something different with templates.

from mandrill_mailer.

jonyt avatar jonyt commented on September 15, 2024

I'm using:
mandrill-api (1.0.53)
mandrill_mailer (0.5.1)

On Mon, Feb 23, 2015 at 4:02 PM, Adam Rensel [email protected]
wrote:

Interesting.. using their api example runner, I wasn't seeing any errors.
This gem pretty much does what your above code does and calls the api
directly:
https://github.com/renz45/mandrill_mailer/blob/master/lib/mandrill_mailer/template_mailer.rb#L116

What version of the api gem are you using to run that above code? I'm
wondering if a newer version does something different with templates.


Reply to this email directly or view it on GitHub
#73 (comment)
.

Got a cool idea for a web startup? How about I build it for you? Check out
http://chapter64.com/

from mandrill_mailer.

jonyt avatar jonyt commented on September 15, 2024

I just ran it again and it raises no exception. Weird. Let me investigate.

On Mon, Feb 23, 2015 at 4:05 PM, Jonathan Yom-Tov [email protected]
wrote:

I'm using:
mandrill-api (1.0.53)
mandrill_mailer (0.5.1)

On Mon, Feb 23, 2015 at 4:02 PM, Adam Rensel [email protected]
wrote:

Interesting.. using their api example runner, I wasn't seeing any errors.
This gem pretty much does what your above code does and calls the api
directly:
https://github.com/renz45/mandrill_mailer/blob/master/lib/mandrill_mailer/template_mailer.rb#L116

What version of the api gem are you using to run that above code? I'm
wondering if a newer version does something different with templates.


Reply to this email directly or view it on GitHub
#73 (comment)
.

Got a cool idea for a web startup? How about I build it for you? Check out
http://chapter64.com/

Got a cool idea for a web startup? How about I build it for you? Check out
http://chapter64.com/

from mandrill_mailer.

renz45 avatar renz45 commented on September 15, 2024

Ahh so we're pretty far behind (this gem uses 0.5.1). I'll try to find some time to upgrade the api gem, which will probably fix this issue. Let know if that's something you wouldn't mind doing, at a glance it looks like the api is the same. I'll merge in the PR and bump it a major version if you do. :)

from mandrill_mailer.

renz45 avatar renz45 commented on September 15, 2024

If not, I can probably get to this Wednesday or Thursday.

from mandrill_mailer.

jonyt avatar jonyt commented on September 15, 2024

Sure.

On Mon, Feb 23, 2015 at 4:15 PM, Adam Rensel [email protected]
wrote:

If not, I can probably get to this Wednesday or Thursday.


Reply to this email directly or view it on GitHub
#73 (comment)
.

Got a cool idea for a web startup? How about I build it for you? Check out
http://chapter64.com/

from mandrill_mailer.

jonyt avatar jonyt commented on September 15, 2024

For future reference:

A mandrill error occurred: Mandrill::UnknownTemplateError - No such template "non-existent"
/home/jonyt/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/mandrill-api-1.0.53/lib/mandrill.rb:92:in `cast_error': No such template "non-existent" (Mandrill::UnknownTemplateError)
    from /home/jonyt/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/mandrill-api-1.0.53/lib/mandrill.rb:37:in `call'
    from /home/jonyt/.rvm/rubies/ruby-2.1.4/lib/ruby/gems/2.1.0/gems/mandrill-api-1.0.53/lib/mandrill/api.rb:921:in `send_template'
    from /home/jonyt/dev/mandrill.rb:10:in `'

from mandrill_mailer.

renz45 avatar renz45 commented on September 15, 2024

I apologize, this completely fell off my radar apparently. I've set aside some time this friday to look at this and the other issue in the queue. I'm also going to do some cleanup on duplicate code between the two mailers.

from mandrill_mailer.

renz45 avatar renz45 commented on September 15, 2024

I worked on this a bit Friday. Mostly cleaning up code resulting from various pull requests, getting rid of a lot of duplication and supporting all available attributes from the messages api. It needs a few more specs but it looks like the new mandrill-api version doesn't affect much which is nice. These changes can be found on the v1 branch

Going to try to finish it this week.

from mandrill_mailer.

renz45 avatar renz45 commented on September 15, 2024

I just released version 1.0, which includes updating the mandrill_api gem to the latest version, which should solve this issue.

from mandrill_mailer.

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.