[ruby-core:113363] [Ruby master Feature#19620] allow non-module rescue filters that implement the === opertor

Issue #19620 has been reported by bughit (bug hit). ---------------------------------------- Feature #19620: allow non-module rescue filters that implement the === opertor https://bugs.ruby-lang.org/issues/19620 * Author: bughit (bug hit) * Status: Open * Priority: Normal ---------------------------------------- ```ruby 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. ```ruby begin raise 'foo error' rescue ->e{e.message =~ /foo/} p e.message end ``` -- https://bugs.ruby-lang.org/
participants (1)
-
bughit (bug hit)