lib/jss-api/db_connection.rb in jss-api-0.5.6 vs lib/jss-api/db_connection.rb in jss-api-0.5.7

- old
+ new

@@ -161,11 +161,15 @@ args[:write_timeout] ||= DFT_TIMEOUT args[:port] ||= Mysql::MYSQL_TCP_PORT args[:socket] ||= DFT_SOCKET args[:db_name] ||= DEFAULT_DB_NAME - @mysql.close if connected? + begin + @mysql.close if connected? + rescue Mysql::ClientError::ServerGoneError + @connected = false + end @server = args[:server] @port = args[:port] @socket = args[:socket] @mysql_name = args[:db_name] @@ -179,10 +183,10 @@ # passwd from prompt, stdin, or args? raise JSS::MissingDataError, "Missing :pw (or :prompt/:stdin) for user '#{@user}'" unless args[:pw] @pw = if args[:pw] == :prompt - JSS.prompt_for_password "Enter the password for the MySQL user '#{@user}':" + JSS.prompt_for_password "Enter the password for the MySQL user #{@user}@#{args[:server]}:" elsif args[:pw].is_a?(Symbol) and args[:pw].to_s.start_with?('stdin') args[:pw].to_s =~ /^stdin(\d+)$/ line = $1 line ||= 2 JSS.stdin line