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.
-
- (Array) setup_error_handling(entries, fatal)
Setups error handling.
-
- (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 |
# File 'lib/bovem/shell.rb', line 21 def handle_failure(e, access_error, not_found_error, general_error, entries, fatal, show_errors) error_type, locale, final_entries = setup_error_handling(entries, fatal) case e.class.to_s when "Errno::EACCES" then @console.send(error_type, locale.send(access_error, final_entries)) when "Errno::ENOENT" then @console.send(error_type, locale.send(not_found_error, final_entries)) else show_general_failure(e, general_error, entries, fatal) if show_errors end end |
- (Array) setup_error_handling(entries, fatal)
Setups error handling.
36 37 38 |
# File 'lib/bovem/shell.rb', line 36 def setup_error_handling(entries, fatal) [fatal ? :fatal : :error, self.i18n.shell, entries.length == 1 ? entries[0] : entries] end |
- (Object) show_general_failure(e, general_error, entries, fatal)
Shows errors when a directory creation failed.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bovem/shell.rb', line 45 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 |