るりまサーチ

最速Rubyリファレンスマニュアル検索!
147件ヒット [1-100件を表示] (0.195秒)

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Exception#message -> String (26114.0)

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

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

//emlist[例][ruby]{
begin

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

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

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

...なら :top です。

//emlist[例][ruby]{
begin

raise "test"
rescue => e
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
$stderr = $stdout
p e.full_message # => "test.rb:2:in `<main>': test (Runt...
...imeError)\n"
$stderr = STDERR
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
end
//}

@see Exception.to_tty?...

Exception#to_s -> String (11014.0)

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

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

//emlist[例][ruby]{
begin

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

Exception#exception(error_message) -> Exception (8146.0)

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

...Exception#message 属性を error_message にして返します。

Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。

@param error_message エラーメッセージを表す文字列を指定します。

//emlist[例][ruby]{
begin

# ......

Thread#raise(error_type, message, traceback) -> () (8114.0)

自身が表すスレッドで強制的に例外を発生させます。

...ype Kernel.#raise を参照してください。

@param message Kernel.#raise を参照してください。

@param traceback Kernel.#raise を参照してください。

Thread.new {
sleep 1
Thread.main.raise "foobar"
}

begin

sleep
rescue
p $!, $@
end

=> #<RuntimeEr...

絞り込み条件を変える

Exception#exception -> self (8046.0)

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

...Exception#message 属性を error_message にして返します。

Kernel.#raise は、実質的に、例外オブジェクトの exception
メソッドの呼び出しです。

@param error_message エラーメッセージを表す文字列を指定します。

//emlist[例][ruby]{
begin

# ......

Exception#==(other) -> bool (8041.0)

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

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

@param other 自身と比較したいオブジェクトを指定します。...
...onth"
end

def get_exception
return begin
yield
rescue => e
e
end
end

results = [2, 2, 4].map { |e | get_exception { check_long_month(e) } }
p results.map { |e| e.class }
# => [RuntimeError, RuntimeError, RuntimeError]
p results.map { |e| e.message }
# => ["2 is not long month", "2 is...
...not long month", "4 is not long month"]

# class, message, backtrace が同一のため true になる
p results[0] == results[1] # => true

# class, backtrace が同一だが、message がことなるため false になる
p results[0] == results[2] # => false
//}...

Exception#inspect -> String (8023.0)

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

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

//emlist[例][ruby]{
begin

raise "exception"
rescue
p $!.inspect # => "#<RuntimeError: exception>"
end
//}...

SignalException#signm -> String (8023.0)

self.message のエイリアスです。

...self.message のエイリアスです。

//emlist[例][ruby]{
begin

Process.kill('HUP', Process.pid)
sleep
rescue SignalException => e
puts e.signm # => SIGHUP
end
//}...

SystemCallError#errno -> Integer | nil (8019.0)

レシーバに対応するシステム依存のエラーコードを返します。

...形式で生成した場合は nil を返します。

begin

raise Errno::ENOENT
rescue Errno::ENOENT => err
p err.errno # => 2
p Errno::ENOENT::Errno # => 2
end

begin

raise SystemCallError, 'message'
rescue SystemCallError => err
p err.errno...

絞り込み条件を変える

<< 1 2 > >>