Actions
Feature #19620
openallow non-module rescue filters that implement the === opertor
    Feature #19620:
    allow non-module rescue filters that implement the === opertor
  
Status:
Open
Assignee:
-
Target version:
-
Description
module FooErrorFilter
  def self.===(e)
    e.message =~ /foo/
  end
end
def foo_error_filter
  FooErrorFilter
end
begin
  raise 'foo error'
rescue foo_error_filter => e
  p e.message
end
Filter matching is done via the === operator, which is why the rescue filter modules don't need to be exception classes. But they are required to be modules, why? Since the rescue filter object is only used for the === operator it should accept any object supporting it. The module restriction seems arbitrary and pointless.
begin
  raise 'foo error'
rescue ->e{e.message =~ /foo/}
  p e.message
end
  
        
          
          Updated by byroot (Jean Boussier) over 2 years ago
          
          
        
        
      
      - Related to Bug #4438: rescue args type check omitted added
 
Actions