# File rice/icemachine.rb, line 103 def retrieveErrorCodeFrom(reply, requestId) err = errPhrase = nil errMessage = '' parser = NQXML::Dispatcher.new(reply) parser.handle(start_element:start_element, ERROR_CODE_XML_CONTEXT) { | entity | # Check for proper request id in reply (else it's # not for us right now). if entity.attrs['message-id'] != requestId.to_s # This isn't a standard ICE error. return "REPLY ID #{entity.attrs['message-id']}" + " DOES NOT MATCH REQUEST ID #{requestId}" end err = entity.attrs['numeric'].to_i errPhrase = entity.attrs['phrase'] } parser.handle(text:text, ERROR_CODE_XML_CONTEXT) { | entity | # If the text is CDATA, it has already been handled correctly # by the parser: the CDATA begin/end tags have been stripped # off. (Actually, they are in entity.source if you really want # 'em.) if err # We are grabbing the ice-code error message. errMessage = entity.text end } parser.start() return err, "Error [#{err} (#{errPhrase})]: #{errMessage} #{reply}" end