このマニュアルは既にメンテナンスが終了したバージョンの Ruby を対象としています。 最新版のマニュアルへ

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

singleton method Exception.new

new(error_message = nil) -> Exception[permalink][rdoc][edit]

例外オブジェクトを生成して返します。

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

[SEE_ALSO] Exception.exception