lib/conjur/cli.rb in conjur-cli-5.6.6 vs lib/conjur/cli.rb in conjur-cli-6.0.0.rc1

- old
+ new

@@ -35,10 +35,11 @@ module Conjur autoload :Config, 'conjur/config' autoload :Log, 'conjur/log' autoload :IdentifierManipulation, 'conjur/identifier_manipulation' autoload :Authn, 'conjur/authn' + autoload :Authenticator, 'conjur/authenticator' autoload :Command, 'conjur/command' autoload :DSL, 'conjur/dsl/runner' autoload :DSLCommand, 'conjur/command/dsl_command' autoload :VERSION, 'conjur/version' @@ -115,11 +116,11 @@ pre do |global,command,options,args| require 'conjur/api' if command.name_for_help.first == "init" and options.has_key?("account") - ENV["CONJUR_ACCOUNT"]=options["account"] + ENV["CONJUR_ACCOUNT"] = options["account"] end apply_config require 'active_support/core_ext' options.delete_if{|k,v| v.blank?} options.symbolize_keys! @@ -152,15 +153,21 @@ run_default_handler = true if @current_command != nil && !command_version_compatible?(@current_command) $stderr.puts "error: this command is not supported by the current Conjur server version" run_default_handler = false elsif exception.is_a?(RestClient::Exception) && exception.response - err = Conjur::Error.create exception.response.body - if err - $stderr.puts "error: " + err.message - run_default_handler = false # suppress default error message + if exception.http_code == 401 + $stderr.puts "Unable to authenticate with Conjur. Please check your credentials." + run_default_handler = false else - $stderr.puts exception.response.body + err = Conjur::Error.create exception.response.body + + if err + $stderr.puts "error: " + err.message + run_default_handler = false # suppress default error message + else + $stderr.puts exception.response.body + end end end run_default_handler end