R
R
Roman Mirilaczvili2016-06-27 11:28:56
Ruby on Rails
Roman Mirilaczvili, 2016-06-27 11:28:56

How to catch all internal exceptions of the RoR framework?

Is there some way to only catch internal exceptions that are used by the RoR framework itself, but not by other frameworks? Let's say ActionController::RoutingError, and many others. Maybe they have a common ancestor?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Karim Kyatlottyavi, 2016-06-28
@2ord

As for the ancestors, using the ancestors method, you can suggest that the ActionController::RoutingError has a base rail class ActionController::ActionControllerError (which already goes back to the ruby ​​StandardError).

2.3.1 :029 > ActionController::RoutingError.ancestors
 => [ActionController::RoutingError, 
ActionController::ActionControllerError, 
StandardError, Exception, ActiveSupport::Dependencies::Blamable, 
Object, PP::ObjectMixin, ActiveSupport::Dependencies::Loadable, 
V8::Conversion::Object, 
JSON::Ext::Generator::GeneratorMethods::Object, 
Kernel, 
BasicObject]

But I'm sure that other Rails components have their own parent exception classes, and maybe even more than one. For example, ActiveRecord has ActiveRecord::ActiveRecordError.
You may have to go through the rails sources and look for classes that inherit from StandardError.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question