Skip to Content

Rails - Error handler order

Posted on

If you want to rescue multiple errors, you should declare general handlers first. (eg: one for StandardError) then specific ones.

For example:

rescue_from StandardError, with: :internal_server_error
rescue_from CustomError, with: :custom_error
rescue_from XXXError, with: :xxx_error

By this way, StandardError > CustomError > XXXError.


comments powered by Disqus