def error_info(hash)      
      if hash && (e = hash["Error"]) && (e["ErrorNumber"] || e["ErrorMessage"])
        return OpenStruct.new(:number => e["ErrorNumber"], :message => e["ErrorMessage"])
      end

      # Or wait! Some API's have a totally different way of reporting errors, great!
      if hash && (e = hash["Authentication"]) && e["Problem"] 
        return OpenStruct.new(:number => e["Problem"]["Code"], :message => e["Problem"]["Message"])
      end

      # And one more for Auth errors! With no error number, hooray. 
      if hash && (e = hash["AuthorizationState"]) && e["State"] == "failed"
        return OpenStruct.new(:number => nil, :message => "AuthorizationState: State: failed")
      end

      # And yet another way!
      if hash && (e = hash["Problem"])
        # Code/Message appear unpredictably at different keys? 
        return OpenStruct.new(:number => e["ErrorCode"] || e["Code"], :message => e["ErrorMessage"] || e["Message"])
      end

      return nil    
    end
def error_info(hash)      
      if hash && (e = hash["Error"]) && (e["ErrorNumber"] || e["ErrorMessage"])
        return OpenStruct.new(:number => e["ErrorNumber"], :message => e["ErrorMessage"])
      end

      # Or wait! Some API's have a totally different way of reporting errors, great!
      if hash && (e = hash["Authentication"]) && e["Problem"] 
        return OpenStruct.new(:number => e["Problem"]["Code"], :message => e["Problem"]["Message"])
      end

      # And one more for Auth errors! With no error number, hooray. 
      if hash && (e = hash["AuthorizationState"]) && e["State"] == "failed"
        return OpenStruct.new(:number => nil, :message => "AuthorizationState: State: failed")
      end

      # And yet another way!
      if hash && (e = hash["Problem"])
        # Code/Message appear unpredictably at different keys? 
        return OpenStruct.new(:number => e["ErrorCode"] || e["Code"], :message => e["ErrorMessage"] || e["Message"])
      end

      return nil    
    end
returns an OpenStruct with #message and #number,
 or nil if error info can not be extracted