Module: Bovem::ShellMethods::General
- Included in:
- Bovem::Shell
- Defined in:
- lib/bovem/shell.rb
Overview
General methods.
Instance Method Summary (collapse)
-
- (Object) handle_failure(e, access_error, not_found_error, general_error, entries, fatal, show_errors)
Handles general failure of a file/directory method.
-
- (Object) show_general_failure(e, general_error, entries, fatal)
Shows errors when a directory creation failed.
Instance Method Details
- (Object) handle_failure(e, access_error, not_found_error, general_error, entries, fatal, show_errors)
Handles general failure of a file/directory method.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bovem/shell.rb', line 21 def handle_failure(e, access_error, not_found_error, general_error, entries, fatal, show_errors) error_type = fatal ? :fatal : :error = e..gsub(/.+ - (.+)/, "\\1") locale = self.i18n.shell case e.class.to_s when "Errno::EACCES" then @console.send(error_type, locale.send(access_error, )) when "Errno::ENOENT" then @console.send(error_type, locale.send(not_found_error, )) else show_general_failure(e, general_error, entries, fatal) if show_errors end end |
- (Object) show_general_failure(e, general_error, entries, fatal)
Shows errors when a directory creation failed.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bovem/shell.rb', line 38 def show_general_failure(e, general_error, entries, fatal) locale = self.i18n.shell @console.error(locale.send(general_error)) @console.with_indentation(11) do entries.each do |entry| @console.write(entry) end end @console.write(locale.error(e.class.to_s, e), "\n", 5) Kernel.exit(-1) if fatal end |