Feature #8912
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
=begin When we have a custom exception class with a custom (({initialize})) `initialize` method whose arity is not (({1})): `1`: class MyException < StandardError def initialize x, y super("Something went wrong with #{x.inspect} because #{y}, blah blah") end end in order to raise it, we have to create a new instance of it explicitly using (({new})), `new`, and embed that under (({Kernel#raise})). `Kernel#raise`. raise(MyException.new(:foo, :bar)) This is inconvenient, and does not look object oriented. I propose that there should be (({Exception#raise})), `Exception#raise`, which is public, so that we can do: MyException.raise(:foo, :bar) A Ruby implementation may be like this: class Exception def self.raise *args; Kernel.send(:raise, *args) end end This will disallow us from calling the private method (({Kernel#raise})) `Kernel#raise` (without an explicit receiver) within the context of an (({Exception})) `Exception` class unless we use (({send})), `send`, but I think such use case is rare, and that should not be a problem. =end