Skip to content

Instantly share code, notes, and snippets.

@RichardJordan
Last active August 29, 2015 13:56
Show Gist options
  • Save RichardJordan/9058865 to your computer and use it in GitHub Desktop.
Save RichardJordan/9058865 to your computer and use it in GitHub Desktop.
Example: error handling
# from this blog post: http://bugroll.com/how-to-write-good-error-messages.html
# an example of good error handling
begin
update_purchase_captured_at!(purchase, captured_at)
rescue Exception => e
Honeybadger.notify(e)
Rails.logger.error(%Q{\
[#{Time.zone.now}][rake purchases:update_captured_at] Error updating \
captured_at for purchase #{purchase.id}: #{e.class}: #{e.message}
This means the funds got captured, but the order will *not* be fulfilled!
Visit http://thepaymentprocess.com/admin and search for transaction ID
#{purchase.transaction_id} for more details on this purchase.
#{e.backtrace}})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment