Posts tagged Exception

ActionMailer Error: hostname was not match with the server certificate

You guys may have stuck with following error while using ActionMailer with Rails 2.2.2 .

OpenSSL::SSL::SSLError (hostname was not match with the server certificate):
    /usr/lib/ruby/1.8/openssl/ssl.rb:123:in `post_connection_check'
    /usr/lib/ruby/1.8/net/smtp.rb:582:in `tlsconnect'
    /usr/lib/ruby/1.8/net/smtp.rb:562:in `do_start'
    /usr/lib/ruby/1.8/net/smtp.rb:525:in `start'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:671:in `perform_delivery_smtp'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:526:in `__send__'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:526:in `deliver!'
    /vendor/rails/actionmailer/lib/action_mailer/base.rb:392:in `method_missing'
    /app/controllers/users_controller.rb:40:in `send_email_to_confirm_user'

Actually, Rails 2.2.2 turn on STARTTLS if it is available in Net::SMTP (added in Ruby 1.8.7) and the SMTP server supports it.

If you use postfix, then you fix it quickly by disabling tls by setting “smtpd_use_tls=no” in /etc/postfix/main.cf .

Remember to restart postfix and rails app server.

Terminate called after throwing an instance of ‘int’

Ever faced “terminate called after throwing an instance of ‘int’ ” error in RubyOnRails?
or
Specially on linux machine only not on windows.

Error occurred specially when dealing with some image handling, or with attachment_fu.

The cause of this error is image_science 1.1.3 . Add :processor => “Rmagick” to has_attachment options and get rid of this problem.

Enjoy!!!

Exceptional: Another rails application exception tracking application

Some days ago I found HopToad, as a subtitute of exception notifier plugin. Now, today I found another rails exception tracking application named Exceptional. Hoptoad is free while exceptional is paid. :)

Hoptoad: A Rails Exception Handling Service

Many of you guys(as me) may have used Exception Notifier plugin to get Rails app exceptions right into your mailbox, and may also have faced some problem like this.

Also if you have 2-3 or more apps running in production then managing such exception mails is also a big headache. In such case one have to keep track of many things like which type of error is resolved/unresolved for which project etc… .

So, here is a good news for those who don’t know about Hoptoad. It is an hosted service by thoughtbot which receives your exceptions, notify you once per error type by email and keep track(resolved/unresolved, count etc…) of your errors on project basis.

By now its a free service. I’m gonna use this as my next project goes live. What abt you??? ;-P

Git Error: trailing whitespace, indent SP followed by a TAB, unresolved merge conflict

I have been using Git from last few days, and faced following errors while committing:

1) Trailing whitespace
2) Indent SP followed by a TAB
3) Unresolved merge conflict

The first error “Trailing whitespace” is because of carriage-return/line-feed(windows style line feed/end). To resolve this problem comment following lines(58-60) in .git/hooks/pre-commit file:

  if (/\s$/) {
    bad_line("trailing whitespace", $_);
 }

The second one “Indent SP followed by a TAB” is because of leading spaces/tabs. To resolve this problem comment following lines(61-63) in .git/hooks/pre-commit file:

  if (/^\s*   /) {
    bad_line("indent SP followed by a TAB", $_);
  }

The third one “Unresolved merge conflict” is because of seven or more successive occurrence of = or < or > characters. Major chances of having seven = character in README or doc files. To resolve this problem replace following line(64) in .git/hooks/pre-commit file:

  if (/^(?:[<>=]){7}/) {

by

  if (/^(?:[<>=]){7}$/) {

These tricks worked for me, I hope it could help you.

Careful while using Exception Notifier Plugin

Exception Notifier Plugin can make you crazy as it made me yesterday.

Let me explain, I was using this plugin for one of my project and our server got a DOS attack. We were requested some URLs that doesn’t exists, like http://somedomain.com/game.rar etc… . I had registered my gmail account to get notification mails. And due to this attack I was sent around 7631*61 mails in 10 hrs. This made me crazy, because I was unable to receive any other email as (may be) my queue was busy with receiving notification mails. Then gmail started bouncing back those mails saying “The Gmail user you are trying to contact is receiving mail at a rate that prevents additional messages from being delivered. Please resend your message at a later
time”
. And then it became a loop, Gmail-My Server-Gmail.

I found 303552 mails in postfix queue of my server. That were ready to send to gmail. Now my first priority was to clean that postfix queue, so I did it by issuing “sudo postsuper -d ALL”. I hope to receive mails ASAP, It is now more than 48 hrs i received any genuine mail.

So I request you to be careful while using this plugin ;-)

Note: Since my gmail account not receiving mails, so please sent it to akhil at vinsol dot com

Plugin: Exception Notifier; Get detail information of exceptions occurred on the live server right on your inbox.

I don’t know whether you guys are aware of Exception Notifier plugin written by Jamis Buck or not. If you don’t then I would like to share this with you.

The Exception Notifier plugin provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application. The plugin is configurable and allows programmers to specify:

  • the sender address of the email
  • the recipient addresses
  • the text used to prefix the subject line

The email includes information about the current request, session, and environment, and also gives a backtrace of the exception.

I am using this plugin and found it very useful, and suggest you to use it.

You can get this plugin from http://dev.rubyonrails.org/svn/rails/plugins/exception_notification/