るりまサーチ

最速Rubyリファレンスマニュアル検索!
18件ヒット [1-18件を表示] (0.028秒)
トップページ > クエリ:message[x] > クエリ:exception[x] > 種類:ライブラリ[x]

別のキーワード

  1. etc sc_message_passing
  2. etc sc_2_pbs_message
  3. getoptlong error_message
  4. mkmf message
  5. optparse message

キーワード

検索結果

e2mmap (115.0)

例外クラスに特定のエラーメッセージ用フォーマットを関連づけるためのライブラリです。

...Exception2MessageMapper を extend すれば、
def_e2message メソッドや def_exception メソッドが使えます。
これらで例外クラスとメッセージを関連づけることができます。

例:

class Foo
extend Exception2MessageMapper
def_e2message ExistingException...
...Class, "message..."
def_exception :NewExceptionClass, "message...", StandardError
...
end

foo = Foo.new
foo.Fail ....

2. 何度も使いたい例外クラスは、クラスの代わりにモジュールで定義して、
それを include して使います。

例:

module Error...
...Mod
extend Exception2MessageMapper
def_e2message ExistingExceptionClass, "message..."
def_exception :NewExceptionClass, "message...", StandardError
...
end
class Foo
include ErrorMod
...
end

foo = Foo.new
foo.Fail ....

3. 例外を設定したクラスのイン...

logger (19.0)

ログを記録するためのライブラリです。

...unless line =~ /^(\w+) = (.*)$/
logger.error("Line in wrong format: #{line.chomp}")
end
end
rescue => err
logger.fatal("Caught exception; exiting")
logger.fatal(err)
end
//}

上の例ではログにはWARN、ERROR、FATALのみが記録されます。
例外オブジェクト...
...出力例です。

W, [2017-12-07T02:22:53.649000 #11601] WARN -- : Nothing to do!
F, [2017-12-07T02:22:53.649172 #11601] FATAL -- : Caught exception; exiting
F, [2017-12-07T02:22:53.649222 #11601] FATAL -- : No such file or directory @ rb_sysopen - a_non_existent_file (Errno::ENOENT)
logg...
...とその場合のログの例は以下のようになります。

フォーマット:

SeverityID, [DateTime #pid] SeverityLabel -- ProgName: message

例:

I, [1999-03-03T02:34:24.895701 #19074] INFO -- Main: info.

Logger#datetime_format= を用いてログに記録する時の日時のフ...