Exception: Cisco::CliError

Inherits:
RequestFailed show all
Defined in:
lib/cisco_node_utils/exceptions.rb

Overview

Extension of RequestFailed class specifically for CLI errors

Instance Attribute Summary

Attributes inherited from CiscoError

#kwargs

Instance Method Summary collapse

Methods inherited from CiscoError

#method_missing, #respond_to?

Constructor Details

#initialize(message = nil, clierror: nil, rejected_input: nil, successful_input: [], **kwargs) ⇒ CliError

Returns a new instance of CliError.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cisco_node_utils/exceptions.rb', line 65

def initialize(message=nil,
               clierror:         nil,
               rejected_input:   nil,
               successful_input: [],
               **kwargs)
  unless message
    if rejected_input.is_a?(Array)
      if rejected_input.length > 1
        message = "The following commands were rejected:\n"
        message += "  #{rejected_input.join("\n  ")}\n"
      else
        message = "The command '#{rejected_input.first}' was rejected "
      end
    else
      message = "The command '#{rejected_input}' was rejected "
    end
    message += "with error:\n#{clierror}"
  end
  super(message,
        :clierror => clierror,
        :rejected_input => rejected_input,
        :successful_input => successful_input,
        **kwargs)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cisco::CiscoError