種類
- モジュール関数 (132)
- インスタンスメソッド (88)
- 特異メソッド (44)
- クラス (33)
- 変数 (11)
クラス
- SystemCallError (55)
- Thread (22)
-
Thread
:: Backtrace :: Location (55)
モジュール
- Kernel (143)
キーワード
-
$ @ (11) - === (11)
- Location (11)
- Status (11)
- SystemCallError (11)
-
absolute
_ path (11) -
backtrace
_ locations (22) -
base
_ label (11) -
caller
_ locations (22) - errno (11)
- fail (33)
- inspect (11)
- new (33)
- path (11)
- raise (33)
-
set
_ trace _ func (11) -
to
_ s (11)
検索結果
先頭5件
-
Kernel
. # caller(range) -> [String] | nil (35301.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......m range 取得したいスタックの範囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
ba......caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(cal... -
Kernel
. # caller(start = 1) -> [String] | nil (35301.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......m range 取得したいスタックの範囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
ba......caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(cal... -
Kernel
. # caller(start , length) -> [String] | nil (35301.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......m range 取得したいスタックの範囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
ba......caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]
end
end
def foo
p parse_caller(cal... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (23222.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...ムを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@param range 取得......Range オブジェクトを指定します。
//emlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(s......t, length)
end
caller_locations # => []
test3(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.... -
Kernel
. # caller _ locations(start = 1 , length = nil) -> [Thread :: Backtrace :: Location] | nil (23222.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...ムを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@param range 取得......Range オブジェクトを指定します。
//emlist[例][ruby]{
def test1(start, length)
locations = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end
def test2(start, length)
test1(start, length)
end
def test3(start, length)
test2(s......t, length)
end
caller_locations # => []
test3(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.... -
SystemCallError (20002.0)
-
Ruby の実装に用いられているシステムコールまたは一部の C 言語関数が失敗した時に発生する例外です。 システムコールの失敗した原因を表すエラーコードを保持します。
...。
多くの場合、実際には SystemCallError そのものではなく
サブクラスである Errno::EXXX (XXX はエラーコードの値によって異なる。
システム定義のエラー名と同じ名前) が発生します。
詳しくは Errno::EXXX を参照してください。... -
SystemCallError
# errno -> Integer | nil (17202.0) -
レシーバに対応するシステム依存のエラーコードを返します。
...します。
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 # => nil
end
なお、例......外を発生させずにエラーコードを得るには、
Errno::EXXX::Errno 定数を使います。... -
SystemCallError
. new(errno) -> SystemCallError (17202.0) -
整数 errno に対応する Errno::EXXX オブジェクトを生成して返します。
...整数 errno に対応する Errno::EXXX オブジェクトを生成して返します。
整数 errno をシステムコールで発生したエラーの原因を示すコードであると解釈し、
対応する例外クラスのインスタンスを生成して返します。
生成される......は SystemCallError の直接のインスタンスではなく、サブクラスのインスタンスです。
それらのサブクラスは Errno モジュール内に定義されています。
対応するサブクラスが存在しないコードを与えた場合には、 SystemCallError の......しくは Errno::EXXX を参照してください。
@param error_message エラーメッセージを表す文字列
@param errno システム依存のエラーコード
@raise TypeError errno を整数に変換できないときに発生します。
例:
p SystemCallError.new("message", 2)... -
SystemCallError
. new(error _ message) -> SystemCallError (17202.0) -
SystemCallError オブジェクトを生成して返します。
...SystemCallError オブジェクトを生成して返します。
@param error_message エラーメッセージを表す文字列
例:
p SystemCallError.new("message")
# => #<SystemCallError: unknown error - message>... -
SystemCallError
. new(error _ message , errno) -> SystemCallError (17202.0) -
整数 errno に対応する Errno::EXXX オブジェクトを生成して返します。
...整数 errno に対応する Errno::EXXX オブジェクトを生成して返します。
整数 errno をシステムコールで発生したエラーの原因を示すコードであると解釈し、
対応する例外クラスのインスタンスを生成して返します。
生成される......は SystemCallError の直接のインスタンスではなく、サブクラスのインスタンスです。
それらのサブクラスは Errno モジュール内に定義されています。
対応するサブクラスが存在しないコードを与えた場合には、 SystemCallError の......しくは Errno::EXXX を参照してください。
@param error_message エラーメッセージを表す文字列
@param errno システム依存のエラーコード
@raise TypeError errno を整数に変換できないときに発生します。
例:
p SystemCallError.new("message", 2)...