-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Suppose you have an error hierarchy as below:
module APIErrors
class ParentError < StandardError; end
class Child < ParentError; end
endIn the API file, suppose you then attempt to rescue from all errors in a standard way:
rescue_from APIErrors::ParentError do |e|
Rack::Response.new({
error: "#{e.class} error",
message: e.message
}.to_json, e.status)
endNow suppose a Child error is raised:
raise APIErrors::Child, "Rescue me, please!"Because the middleware checks only for a list of classes in rescuable?(klass) and the Child class is not included in the list, it will never rescue this.
Is there a way to have all ParentError-derivative classes be rescued?
Metadata
Metadata
Assignees
Labels
No labels