Class: Aspera::Cli::Hints
- Inherits:
-
Object
- Object
- Aspera::Cli::Hints
- Defined in:
- lib/aspera/cli/hints.rb
Overview
Provide hints on errors
Class Method Summary collapse
Class Method Details
.hint_for(error, formatter) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/aspera/cli/hints.rb', line 74 def hint_for(error, formatter) ERROR_HINTS.each do |hint| next unless error.is_a?(hint[:exception]) = error. matches = hint[:match] matches = [matches] unless matches.is_a?(Array) matches.each do |m| Aspera.assert_values(m.class, [String, Regexp]) case m when String next unless .eql?(m) when Regexp next unless .match?(m) else Aspera.error_unexpected_value(m) end remediation = hint[:remediation] remediation = [remediation] unless remediation.is_a?(Array) remediation.each{|r|formatter.(:error, "#{Formatter::HINT_FLASH} #{r}")} break end end end |