Ruby 4.1 リファレンスマニュアル

singleton method Exception.exception

exception(error_message = nil) -> Exception[permalink][rdoc][edit]
(?string | _ToS msg) → instance

例外オブジェクトを生成して返します。引数無しの Exception.new と同じです。

[PARAM] error_message:
エラーメッセージを表す文字列を指定します。このメッセージは属性 Exception#message の値になり、デフォルトの例外ハンドラで表示されます。
e = Exception.exception("some message")
p e         # => #<Exception: some message>
p e.message # => "some message"

[SEE_ALSO] Exception.new, Exception#exception