← Back to Upcase

Custom api error handling

(Jon Shumate) #1

I have a namespaced, versioned api (Api::V1::ApiController) and I’m wondering if any of you have any tips for how to handle general errors like NoMethodError. I’d like to be able to return a json error message rather than a normal 500 Internal Server Error.


(Gergely Molnar) #2

I would use rescue_from: http://api.rubyonrails.org/classes/ActiveSupport/Rescuable/ClassMethods.html