Exception: Cisco::YangError

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

Overview

Extension of RequestFailed class specifically for YANG 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, error: nil, rejected_input: nil, successful_input: [], **kwargs) ⇒ YangError

Returns a new instance of YangError.


93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/cisco_node_utils/exceptions.rb', line 93

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

    message += "with error:\n#{error}"
  end
  super(message,
        :error => error,
        :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