예제 #1
0
 private void exception(Ice.Current current)
 {
     if(current.operation.Equals("ice_ids"))
     {
         throw new Test.TestIntfUserException();
     }
     else if(current.operation.Equals("requestFailedException"))
     {
         throw new ObjectNotExistException();
     }
     else if(current.operation.Equals("unknownUserException"))
     {
         UnknownUserException ex = new UnknownUserException();
         ex.unknown = "reason";
         throw ex;
     }
     else if(current.operation.Equals("unknownLocalException"))
     {
         UnknownLocalException ex = new UnknownLocalException();
         ex.unknown = "reason";
         throw ex;
     }
     else if(current.operation.Equals("unknownException"))
     {
         UnknownException ex = new UnknownException();
         ex.unknown = "reason";
         throw ex;
     }
     else if(current.operation.Equals("userException"))
     {
         throw new TestIntfUserException();
     }
     else if(current.operation.Equals("localException"))
     {
         SocketException ex = new SocketException();
         ex.error = 0;
         throw ex;
     }
     else if(current.operation.Equals("csException"))
     {
         throw new System.Exception("message");
     }
     else if(current.operation.Equals("unknownExceptionWithServantException"))
     {
         throw new UnknownException("reason");
     }
     else if(current.operation.Equals("impossibleException"))
     {
         throw new Test.TestIntfUserException(); // Yes, it really is meant to be TestIntfException.
     }
     else if(current.operation.Equals("intfUserException"))
     {
         throw new Test.TestImpossibleException(); // Yes, it really is meant to be TestImpossibleException.
     }
     else if(current.operation.Equals("asyncResponse"))
     {
         throw new Test.TestImpossibleException();
     }
     else if(current.operation.Equals("asyncException"))
     {
         throw new Test.TestImpossibleException();
     }
 }
예제 #2
0
        public override bool Sent() => base.SentImpl(!Proxy.IsTwoway); // done = true if it's not a two-way proxy

        public override bool Response()
        {
            Debug.Assert(Is != null);
            //
            // NOTE: this method is called from ConnectionI.parseMessage
            // with the connection locked. Therefore, it must not invoke
            // any user callbacks.
            //
            Debug.Assert(Proxy.IsTwoway); // Can only be called for twoways.

            if (ChildObserver != null)
            {
                ChildObserver.Reply(Is.Size - Protocol.headerSize - 4);
                ChildObserver.Detach();
                ChildObserver = null;
            }

            byte replyStatus;

            try
            {
                replyStatus = Is.ReadByte();

                switch (replyStatus)
                {
                case ReplyStatus.replyOK:
                    {
                        break;
                    }

                case ReplyStatus.replyUserException:
                {
                    if (Observer != null)
                    {
                        Observer.UserException();
                    }
                    break;
                }

                case ReplyStatus.replyObjectNotExist:
                case ReplyStatus.replyFacetNotExist:
                case ReplyStatus.replyOperationNotExist:
                {
                    var ident = new Ice.Identity(Is);

                    //
                    // For compatibility with the old FacetPath.
                    //
                    string[] facetPath = Is.ReadStringArray();
                    string   facet;
                    if (facetPath.Length > 0)
                    {
                        if (facetPath.Length > 1)
                        {
                            throw new Ice.MarshalException();
                        }
                        facet = facetPath[0];
                    }
                    else
                    {
                        facet = "";
                    }

                    string operation = Is.ReadString();

                    Ice.RequestFailedException ex;
                    switch (replyStatus)
                    {
                    case ReplyStatus.replyObjectNotExist:
                    {
                        ex = new Ice.ObjectNotExistException();
                        break;
                    }

                    case ReplyStatus.replyFacetNotExist:
                    {
                        ex = new Ice.FacetNotExistException();
                        break;
                    }

                    case ReplyStatus.replyOperationNotExist:
                    {
                        ex = new Ice.OperationNotExistException();
                        break;
                    }

                    default:
                    {
                        Debug.Assert(false);
                        throw new System.InvalidOperationException();
                    }
                    }

                    ex.Id        = ident;
                    ex.Facet     = facet;
                    ex.Operation = operation;
                    throw ex;
                }

                case ReplyStatus.replyUnknownException:
                case ReplyStatus.replyUnknownLocalException:
                case ReplyStatus.replyUnknownUserException:
                {
                    string unknown = Is.ReadString();

                    Ice.UnknownException ex;
                    switch (replyStatus)
                    {
                    case ReplyStatus.replyUnknownException:
                    {
                        ex = new Ice.UnknownException();
                        break;
                    }

                    case ReplyStatus.replyUnknownLocalException:
                    {
                        ex = new Ice.UnknownLocalException();
                        break;
                    }

                    case ReplyStatus.replyUnknownUserException:
                    {
                        ex = new Ice.UnknownUserException();
                        break;
                    }

                    default:
                    {
                        Debug.Assert(false);
                        throw new System.InvalidOperationException();
                    }
                    }

                    ex.Unknown = unknown;
                    throw ex;
                }

                default:
                {
                    throw new Ice.UnknownReplyStatusException();
                }
                }

                return(ResponseImpl(false, replyStatus == ReplyStatus.replyOK, true));
            }
            catch (Ice.Exception ex)
            {
                return(Exception(ex));
            }
        }