Skip to content

Instantly share code, notes, and snippets.

@mmcdaris
Last active August 29, 2015 13:57
Show Gist options
  • Save mmcdaris/9633230 to your computer and use it in GitHub Desktop.
Save mmcdaris/9633230 to your computer and use it in GitHub Desktop.
airbrake ignore experiments
# Returns an exception of your choice
# = Usage
# route_error = exception_of_type(ActionController::RoutingError)
# url_error = exception_of_type(ActionController::UrlGenerationError)
def exception_of_type(type, args = nil)
type.new StandardError.new(args)
end
# Gets an Airbrake::Notice object for the exception
# = Usage
# e = StandardError.new("test test test")
# n = get_airbrake_notice(e)
def get_airbrake_notice(e)
hash = Airbrake.build_lookup_hash_for(e)
Airbrake::Notice.new(Airbrake.configuration.merge(hash))
end
# Returns a boolean based on ignore? status
# = Usage
# e = StandardError.new("no more cat food!")
def error_ignored?(e)
get_airbrake_notice(e).ignore?
end
# Will airbrake ignore this class? Returns 'Yes' or 'No'
# = Usage
# airbrake_ignores?(ActionController::RoutingError)
# airbrake_ignores?(ActionController::UrlGenerationError)
def airbrake_ignores?(class_name)
error_ignored?(exception_of_type(class_name)) ? "Yes" : "No"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment