Reputation: 1772
I have created a my first API service using the Grape GEM and Rails. The API's work perfectly, but I'm struggling with Error handling and the search for valuable tutorials have been without result.
In the tutorial that I followed, the only Error handling coverage they followed was this:
rescue_from ActiveRecord::RecordNotFound do |e|
error!(message: e.message, status: 404)
end
rescue_from ActiveRecord::RecordInvalid do |e|
error!(message: e.message, status: 422)
end
Two Issues have led me to the conclusion that this is not sufficient:
Can anyone point me to a tutorial that's fully focussed on Grape exception handling? I am so confused with regards to handling Model Validations through API calls etc. and could do with some guidance.
Upvotes: 1
Views: 2636
Reputation: 5144
You can check those link:
http://code.dblock.org/2011/05/04/grape-trapping-all-exceptions-within-the-api.html
Upvotes: 2