Class: Morpheus::Cli::ErrorHandler
- Inherits:
-
Object
- Object
- Morpheus::Cli::ErrorHandler
- Includes:
- Term::ANSIColor
- Defined in:
- lib/morpheus/cli/error_handler.rb
Instance Method Summary collapse
Instance Method Details
#print_errors(response, options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/morpheus/cli/error_handler.rb', line 11 def print_errors(response, = {}) if [:json] print JSON.pretty_generate(response) else if !response['success'] print red,bold, "\n" if response['msg'] puts response['msg'] end if response['errors'] response['errors'].each do |key, value| print "* #{key}: #{value}\n" end end print reset, "\n" end end end |
#print_rest_exception(e, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/morpheus/cli/error_handler.rb', line 30 def print_rest_exception(e, ={}) if e.response.code == 400 json_response = JSON.parse(e.response.to_s) if [:json] print JSON.pretty_generate(json_response) print "\n" else ::Morpheus::Cli::ErrorHandler.new.print_errors(json_response) end else puts "Error Communicating with the Appliance. Please try again later. #{e}" end end |