lib/ting_yun/support/serialize/marshaller.rb in tingyun_rpm-1.1.4.2 vs lib/ting_yun/support/serialize/marshaller.rb in tingyun_rpm-1.2.0

- old
+ new

@@ -5,25 +5,10 @@ module TingYun module Support module Serialize class Marshaller - def parsed_error(error) - error_code = error['errorCode'] - error_message = error['errorMessage'] - case error_code - when 460 - raise TingYun::Support::Exception::LicenseException.new("#{error_code}: #{error_message}") - when 461 - raise TingYun::Support::Exception::InvalidDataTokenException.new("#{error_code}: #{error_message}") - when 462 - raise TingYun::Support::Exception::InvalidDataException.new("#{error_code}: #{error_message}") - when 470 - raise TingYun::Support::Exception::ExpiredConfigurationException.new("#{error_code}: #{error_message}") - end - end - def prepare(data, options={}) encoder = options[:encoder] || default_encoder if data.respond_to?(:to_collector_array) data.to_collector_array(encoder) elsif data.kind_of?(Array) @@ -48,21 +33,18 @@ end protected def return_value(data) - if data.respond_to?(:has_key?) - if data.has_key?('status') && data.has_key?('result') - if data['status'] =="error" - parsed_error(data['result']) - elsif data['result']['enabled'] == false - raise TingYun::Support::Exception::AgentEnableException.new("sorry,the application is unable to use the tingyun service now ") - else - return data['result'] - end + if data.respond_to?(:has_key?) && data.has_key?('status') + if data['status'] =="error" + raise TingYun::Support::Exception::UnKnownServerException.new("sorry,the application is unable to use the tingyun service now, we should reconnect again ") + else + return data['result'] end + else + raise TingYun::Support::Exception::UnKnownServerException.new("sorry,the application is unable to use the tingyun service now, we should reconnect again ") end - data end end end end end