Created
January 2, 2012 06:39
-
-
Save ilake/1549611 to your computer and use it in GitHub Desktop.
ActionController::Metal and Airbrake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiController < ActionController::Metal | |
include AbstractController::Logger | |
include Rails.application.routes.url_helpers | |
include ActionController::Rendering | |
include ActionController::Renderers::All | |
include ActionController::MimeResponds | |
include AbstractController::Callbacks | |
include Airbrake::Rails::ControllerMethods | |
around_filter :rescue_error | |
protected | |
def rescue_error | |
begin | |
yield | |
rescue ActiveRecord::RecordNotFound => e | |
render :json => { :message => e.message }.to_json, :status => 404 | |
rescue ActiveRecord::RecordInvalid => e | |
render :json => { :message => e.message }.to_json, :status => 400 | |
rescue => e | |
notify_airbrake(e) | |
render :json => { :message => "Internal Error: #{e}" }.to_json, :status => 500 | |
end | |
end | |
end |
Thank you for this! 👍
If anyone comes across this, you just need to upgrade to Airbrake 3.1.17 to fix this error :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Newer versions of Airbrake require