Ruby on Rails
Tuesday, June 28, 2016
This is actually a very bad practice, you are actually creating a black hole that will swallow many relevant problems and will be super hard to debug and maintain in the future. What you want to do is only catch error that you can handle, do not catch everything, you actually have to let most raise and have 2 things: 1) generic message for the users and 2) errors notification system that will send technical details to you and your team, have a look at https://github.com/airbrake/airbrake and get documentation about it. If you want more help, please be more specific about what you want to achieve.
On Mon, Jun 27, 2016 at 9:05 AM, Romiras <romeeras@gmail.com> wrote:
--I'd like to catch any RoR exceptions in REST API application with 'rescue_from'.
rescue_from StandardError do |exception| message = Rails.env.production? ? 'API server error' : exception.message render json: {status: "Error", message: message}, status: :internal_server_error end
but it catches too much irrelevant exceptions. Can I catch RoR exceptions only? Is it a good practice at all? If not, what else you can recommend?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3552a5a5-0bb7-424e-ac75-f8d4c9771198%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANkJ5gm93BajmrqnTcK1mJa_emT614Kou9eepvvKKJ5OL0Yagg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment