Class: Messagex::Exc
- Inherits:
-
Object
- Object
- Messagex::Exc
- Defined in:
- lib/messagex/exc.rb
Overview
I/O関連例外処理管理クラス
Instance Method Summary collapse
-
#exc(msg, exit_codestr, block) ⇒ Object
I/O関連例外処理.
-
#exc_change_directory(arg1, &block) ⇒ Object
ディレクトリ移動失敗例外処理.
-
#exc_file_close(arg1, &block) ⇒ Object
ファイルクローズ失敗例外処理.
-
#exc_file_copy(arg1, arg2, &block) ⇒ Object
ファイルコピー失敗例外処理.
-
#exc_file_gets(arg1, &block) ⇒ Object
ファイル1行読込失敗例外処理.
-
#exc_file_open(arg1, &block) ⇒ Object
ファイルオープン失敗例外処理.
-
#exc_file_read(arg1, &block) ⇒ Object
ファイル読込失敗例外処理.
-
#exc_file_write(arg1, &block) ⇒ Object
ファイル書込失敗例外処理.
-
#exc_make_directory(arg1, &block) ⇒ Object
ディレクトリ作成失敗例外処理.
-
#initialize(mes) ⇒ Exc
constructor
初期化.
Constructor Details
#initialize(mes) ⇒ Exc
初期化
9 10 11 |
# File 'lib/messagex/exc.rb', line 9 def initialize(mes) @mes = mes end |
Instance Method Details
#exc(msg, exit_codestr, block) ⇒ Object
I/O関連例外処理
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/messagex/exc.rb', line 19 def exc(msg, exit_codestr, block) begin block.call rescue IOError => e @mes.output_exception(e) @mes.output_fatal(msg) exit(@mes.ec(exit_codestr)) rescue SystemCallError => e @mes.output_exception(e) @mes.output_fatal(msg) exit(@mes.ec(exit_codestr)) end end |
#exc_change_directory(arg1, &block) ⇒ Object
ディレクトリ移動失敗例外処理
38 39 40 41 42 |
# File 'lib/messagex/exc.rb', line 38 def exc_change_directory(arg1, &block) msg = "Can't change directory to |#{arg1}|" exit_codestr = "EXIT_CODE_CANNOT_CHANGE_DIRECTORY" exc(msg, exit_codestr, block) end |
#exc_file_close(arg1, &block) ⇒ Object
ファイルクローズ失敗例外処理
82 83 84 85 86 |
# File 'lib/messagex/exc.rb', line 82 def exc_file_close(arg1, &block) msg = "Cannot close file #{arg1}" exit_codestr = "EXIT_CODE_CANNOT_OPEN_FILE" exc(msg, exit_codestr, block) end |
#exc_file_copy(arg1, arg2, &block) ⇒ Object
ファイルコピー失敗例外処理
105 106 107 108 109 |
# File 'lib/messagex/exc.rb', line 105 def exc_file_copy(arg1, arg2, &block) msg = "Can't copy file from #{arg1} to #{arg2}" exit_codestr = "EXIT_CODE_CANNOT_COPY_FILE" exc(msg, exit_codestr, block) end |
#exc_file_gets(arg1, &block) ⇒ Object
ファイル1行読込失敗例外処理
71 72 73 74 75 |
# File 'lib/messagex/exc.rb', line 71 def exc_file_gets(arg1, &block) msg = "Cannot read file #{arg1}" exit_codestr = "EXIT_CODE_CANNOT_READ_FILE" exc(msg, exit_codestr, block) end |
#exc_file_open(arg1, &block) ⇒ Object
ファイルオープン失敗例外処理
49 50 51 52 53 |
# File 'lib/messagex/exc.rb', line 49 def exc_file_open(arg1, &block) msg = "Cannot open file #{arg1}" exit_codestr = "EXIT_CODE_CANNOT_OPEN_FILE" exc(msg, exit_codestr, block) end |
#exc_file_read(arg1, &block) ⇒ Object
ファイル読込失敗例外処理
60 61 62 63 64 |
# File 'lib/messagex/exc.rb', line 60 def exc_file_read(arg1, &block) msg = "Cannot read file #{arg1}" exit_codestr = "EXIT_CODE_CANNOT_READ_FILE" exc(msg, exit_codestr, block) end |
#exc_file_write(arg1, &block) ⇒ Object
ファイル書込失敗例外処理
93 94 95 96 97 |
# File 'lib/messagex/exc.rb', line 93 def exc_file_write(arg1, &block) msg = "Cannot write file #{arg1}" exit_codestr = "EXIT_CODE_CANNOT_WRITE_FILE" exc(msg, exit_codestr, block) end |
#exc_make_directory(arg1, &block) ⇒ Object
ディレクトリ作成失敗例外処理
116 117 118 119 120 |
# File 'lib/messagex/exc.rb', line 116 def exc_make_directory(arg1, &block) msg = "Can't make directory to #{arg1}" exit_codestr = "EXIT_CODE_CANNOT_MAKE_DIRECTORY" exc(msg, exit_codestr, block) end |