るりまサーチ

最速Rubyリファレンスマニュアル検索!
102件ヒット [101-102件を表示] (0.015秒)
トップページ > クエリ:exception[x] > クエリ:Exception2MessageMapper[x]

別のキーワード

  1. _builtin exception
  2. exception exception
  3. bigdecimal exception_zerodivide
  4. bigdecimal exception_overflow
  5. bigdecimal exception_nan

ライブラリ

モジュール

キーワード

検索結果

<< < 1 2 >>

e2mmap (84.0)

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

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

例:

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

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

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

例:

module ErrorMod
extend Exception2M...
...essageMapper
def_e2message ExistingExceptionClass, "message..."
def_exception :NewExceptionClass, "message...", StandardError
...
end
class Foo
include ErrorMod
...
end

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

3. 例外を設定したクラスのインスタンス以外から例...
<< < 1 2 >>