/// <summary> /// Reads a reply as an object. /// </summary> /// <param name="expectedType">the expected class if the protocol doesn't supply it.</param> /// <returns>Reply as an object</returns> /// <exception cref="CHessianException"/> public override object ReadReply(Type expectedType) { object objResult = null; int intTag = this.Read(); if (intTag != CHessianProtocolConstants.PROT_REPLY_START) { throw new CHessianException(CHessianProtocolConstants.MESSAGE_WRONG_REPLY_START); } int intMajor = Read(); int intMinor = Read(); intTag = Read(); if (intTag == CHessianProtocolConstants.PROT_REPLY_FAULT) { //throw PrepareFault(); CHessianException wrapper = new CHessianException("received fault", PrepareFault()); wrapper.FaultWrapper = true; throw wrapper; } else { m_intPeek = intTag; objResult = ReadObject(expectedType); CompleteValueReply(); } return(objResult); }
public override void StartReplyBody() { int tag = Read(); if (tag == 'f') { //throw PrepareFault(); CHessianException wrapper = new CHessianException("received fault", PrepareFault()); wrapper.FaultWrapper = true; throw wrapper; } else { m_intPeek = tag; } }
/// <summary> /// Prepares the fault. /// </summary> /// <returns>HessianProtocolException with fault reason</returns> private Exception PrepareFault() { Exception exp = null; Hashtable htFault = this.ReadFault(); object objDetail = htFault["detail"]; string strMessage = (String)htFault["message"]; string exceptionMessage = strMessage; if (objDetail != null && typeof(Exception).IsAssignableFrom(objDetail.GetType())) { exp = objDetail as Exception; } else { exp = new CHessianException(strMessage, (objDetail ?? "").ToString()); } return(exp); }