Exemplo n.º 1
0
        private void handleException(Exception exc, bool amd)
        {
            Debug.Assert(_responseHandler != null);

            if (exc is Ice.SystemException)
            {
                if (_responseHandler.systemException(_current.requestId, (Ice.SystemException)exc, amd))
                {
                    return;
                }
            }

            try
            {
                throw exc;
            }
            catch (Ice.RequestFailedException ex)
            {
                if (ex.id == null || ex.id.name == null || ex.id.name.Length == 0)
                {
                    ex.id = _current.id;
                }

                if (ex.facet == null || ex.facet.Length == 0)
                {
                    ex.facet = _current.facet;
                }

                if (ex.operation == null || ex.operation.Length == 0)
                {
                    ex.operation = _current.operation;
                }

                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    if (ex is Ice.ObjectNotExistException)
                    {
                        _os.writeByte(ReplyStatus.replyObjectNotExist);
                    }
                    else if (ex is Ice.FacetNotExistException)
                    {
                        _os.writeByte(ReplyStatus.replyFacetNotExist);
                    }
                    else if (ex is Ice.OperationNotExistException)
                    {
                        _os.writeByte(ReplyStatus.replyOperationNotExist);
                    }
                    else
                    {
                        Debug.Assert(false);
                    }
                    ex.id.ice_writeMembers(_os);

                    //
                    // For compatibility with the old FacetPath.
                    //
                    if (ex.facet == null || ex.facet.Length == 0)
                    {
                        _os.writeStringSeq(null);
                    }
                    else
                    {
                        string[] facetPath2 = { ex.facet };
                        _os.writeStringSeq(facetPath2);
                    }

                    _os.writeString(ex.operation);

                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UnknownLocalException ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownLocalException);
                    _os.writeString(ex.unknown);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UnknownUserException ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownUserException);
                    _os.writeString(ex.unknown);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    Debug.Assert(_responseHandler != null && _current != null);
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UnknownException ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownException);
                    _os.writeString(ex.unknown);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.UserException ex)
            {
                if (_observer != null)
                {
                    _observer.userException();
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUserException);
                    _os.startEncapsulation(_current.encoding, _format);
                    _os.writeException(ex);
                    _os.endEncapsulation();
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, false);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Ice.Exception ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.ice_id());
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownLocalException);
                    _os.writeString(ex.ice_id() + "\n" + ex.StackTrace);
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }
            catch (Exception ex)
            {
                if (_instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
                {
                    warning(ex);
                }

                if (_observer != null)
                {
                    _observer.failed(ex.GetType().FullName);
                }

                if (_response)
                {
                    _os = new Ice.OutputStream(_instance, Ice.Util.currentProtocolEncoding);
                    _os.writeBlob(Protocol.replyHdr);
                    _os.writeInt(_current.requestId);
                    _os.writeByte(ReplyStatus.replyUnknownException);
                    _os.writeString(ex.ToString());
                    if (_observer != null)
                    {
                        _observer.reply(_os.size() - Protocol.headerSize - 4);
                    }
                    _responseHandler.sendResponse(_current.requestId, _os, _compress, amd);
                }
                else
                {
                    _responseHandler.sendNoResponse();
                }
            }

            if (_observer != null)
            {
                _observer.detach();
                _observer = null;
            }
            _responseHandler = null;
        }
Exemplo n.º 2
0
 public static void write(Ice.OutputStream ostr, string[] v)
 {
     ostr.writeStringSeq(v);
 }