Class: Msf::Ui::Formatter::OptionValidateError
- Inherits:
-
Object
- Object
- Msf::Ui::Formatter::OptionValidateError
- Defined in:
- lib/msf/ui/formatter/option_validate_error.rb
Class Method Summary collapse
-
.print_error(mod, error) ⇒ Object
Print the ‘Msf::OptionValidateError` error in a human readable format.
Class Method Details
.print_error(mod, error) ⇒ Object
Print the ‘Msf::OptionValidateError` error in a human readable format
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/msf/ui/formatter/option_validate_error.rb', line 12 def self.print_error(mod, error) raise ArgumentError, "invalid error type #{error.class}, expected ::Msf::OptionValidateError" unless error.is_a?(::Msf::OptionValidateError) if error.reasons.empty? if error. mod.print_error("#{error.class} #{error.}") else mod.print_error("#{error.class} The following options failed to validate: #{error..join(', ')}") end else mod.print_error("#{error.class} The following options failed to validate:") error..sort.each do |option_name| reasons = error.reasons[option_name] if reasons mod.print_error("Invalid option #{option_name}: #{reasons.join(', ')}") else mod.print_error("Invalid option #{option_name}") end end end end |