Ruby 2.4.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Exceptionクラス > message

instance method Exception#message

message -> String[permalink][rdoc]
to_s -> String

エラーメッセージをあらわす文字列を返します。



begin
  1 + nil
rescue => e
  p e.message   #=>  "nil can't be coerced into Fixnum"
end