Exception for faults when the fault doesn't return a standard exception.
Inheritance: System.Exception
コード例 #1
0
        /// <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 != PROT_REPLY_START)
            {
                throw new CHessianException(MESSAGE_WRONG_REPLY_START);
            }
            int intMajor = Read();
            int intMinor = Read();

            intTag = Read();

            if (intTag == 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);
        }
コード例 #2
0
        /// <summary>
        /// Prepares the fault.
        /// </summary>
        /// <returns>HessianProtocolException with fault reason</returns>
        private Exception PrepareFault()
        {
            Exception exp = null;
            Dictionary <Object, Object> htFault = this.ReadFault();
            object objDetail;

            htFault.TryGetValue("detail", out objDetail);
            object strMessage;

            htFault.TryGetValue("message", out strMessage);
            string exceptionMessage = (String)strMessage;

            if (objDetail != null && typeof(Exception).IsAssignableFrom(objDetail.GetType()))
            {
                exp = objDetail as Exception;
            }
            else
            {
                exp = new CHessianException(exceptionMessage);
            }
            return(exp);
        }
コード例 #3
0
        /// <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 != PROT_REPLY_START)
            {
                throw new CHessianException(MESSAGE_WRONG_REPLY_START);
            }
            int intMajor = Read();
            int intMinor = Read();

            intTag = Read();

            if (intTag == 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;
        }
コード例 #4
0
 /// <summary>
 /// Prepares the fault.
 /// </summary>
 /// <returns>HessianProtocolException with fault reason</returns>
 private Exception PrepareFault()
 {
     Exception exp = null;
     Dictionary<Object, Object> htFault = this.ReadFault();
     object objDetail;
     htFault.TryGetValue("detail", out objDetail);
     object strMessage;
     htFault.TryGetValue("message", out strMessage);
     string exceptionMessage = (String)strMessage;
     if (objDetail != null && typeof(Exception).IsAssignableFrom(objDetail.GetType()))
     {
         exp = objDetail as Exception;
     }
     else
     {
         exp = new CHessianException(exceptionMessage);
     }
     return exp;
 }