Comments (12)
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.
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.
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.
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#L116What 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.
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#L116What 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.
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.
If not, I can probably get to this Wednesday or Thursday.
from mandrill_mailer.
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.
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.
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.
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.
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)
- Template defaults overridden HOT 6
- Suggestion: Interceptor should accept return from proc HOT 2
- assets precompile error HOT 11
- Interceptor Proc params string symbol discrepancy HOT 1
- Delay throwing warning in test_setup_for blocks if email option is missing HOT 4
- vars do not serialize properly when using deliver_later HOT 2
- Amazon SES HOT 3
- problem with template_content key in mandrill_mail(args) HOT 3
- dependent on json-1.8.3? HOT 4
- Optionally not encode attachments and images HOT 1
- Call render_to_string from MandrillMailer::TemplateMailer HOT 1
- Rails 5 support HOT 3
- Attachment not included in mail, yet no errors raised HOT 2
- Not working with rails 5 HOT 5
- Sending through array day as merge_vars HOT 1
- Optionally use 'mandrill_mailer/offline'
- Empty emails HOT 1
- Version 1.8.0 not available on RubyGems HOT 2
- Reject Error
- Unsigned error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mandrill_mailer.