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

class Exception

クラス・モジュールの継承リスト: Exception < Object < Kernel < BasicObject

要約

全ての例外の祖先のクラスです。

特異メソッド

定義 説明
new(error_message = nil) -> Exception
exception(error_message = nil) -> Exception

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

to_tty? -> bool

$stderr が変更されておらず、$stderr.tty? が真の場合は true を返します。

インスタンスメソッド

定義 説明
self == other -> bool

自身と指定された other のクラスが同じであり、 message と backtrace が == メソッドで比較して等しい場合に true を返します。そうでない場合に false を返します。

backtrace -> [String]

バックトレース情報を返します。

backtrace_locations -> [Thread::Backtrace::Location]

バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。

cause -> Exception | nil

self の前の例外(self が rescue 節や ensure 節の中で発生した例外の場合、その前に発生していた元々の例外)を返します。存在しない場合は nil を返します。

exception -> self
exception(error_message) -> Exception

引数を指定しない場合は self を返します。引数を指定した場合 自身のコピーを生成し Exception#message 属性を error_message にして返します。

full_message(highlight: true, order: :bottom) -> String

例外の整形された文字列を返します。

inspect -> String

self のクラス名と message を文字列にして返します。

message -> String
to_s -> String

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

set_backtrace(errinfo) -> nil | String | [String]

バックトレース情報に errinfo を設定し、設定されたバックトレース情報を返します。

継承したメソッド

! != __id__ __send__ instance_eval instance_exec method_missing singleton_method_added singleton_method_removed singleton_method_undefined !~ <=> === =~ _dump class clone define_singleton_method display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? itself marshal_dump marshal_load method methods nil? object_id pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods psych_to_yaml public_method public_methods public_send remove_instance_variable respond_to? respond_to_missing? send singleton_class singleton_method singleton_methods taint tainted? tap then to_a to_ary to_hash to_int to_io to_proc to_regexp to_str trust untaint untrust untrusted? .yaml_tag ::ARGF ::ARGV ::DATA ::ENV ::FALSE ::NIL ::RUBY_COPYRIGHT ::RUBY_DESCRIPTION ::RUBY_ENGINE ::RUBY_ENGINE_VERSION ::RUBY_PATCHLEVEL ::RUBY_PLATFORM ::RUBY_RELEASE_DATE ::RUBY_REVISION ::RUBY_VERSION ::SCRIPT_LINES__ ::STDERR ::STDIN ::STDOUT ::TOPLEVEL_BINDING ::TRUE

追加されるメソッド

定義 説明 ライブラリ
json_create(hash) -> Exception

JSON のオブジェクトから Ruby のオブジェクトを生成して返します。

json/add/exception
to_json(*args) -> String

自身を JSON 形式の文字列に変換して返します。

json/add/exception