Ejemplo n.º 1
0
        public void ShouldHaveMessageAndInnerExceptionInVersionException()
        {
            var e = new VersionException("testMessage", new Exception("testInner"));

            e.Message.Should().Be("testMessage");
            e.InnerException.Message.Should().Be("testInner");
        }
Ejemplo n.º 2
0
        public static IList SerializeExceptionResponse(Exception exc, long requestId, int commandID)

        {
            Alachisoft.NCache.Common.Protobuf.Exception ex = new Alachisoft.NCache.Common.Protobuf.Exception();
            ex.message   = exc.Message;
            ex.exception = exc.ToString();
            if (exc is InvalidReaderException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.INVALID_READER_EXCEPTION;
            }
            else if (exc is OperationFailedException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.OPERATIONFAILED;
            }
            else if (exc is Runtime.Exceptions.AggregateException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.AGGREGATE;
            }
            else if (exc is ConfigurationException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.CONFIGURATION;
            }

            else if (exc is VersionException)
            {
                VersionException tempEx = (VersionException)exc;
                ex.type      = Alachisoft.NCache.Common.Protobuf.Exception.Type.CONFIGURATON_EXCEPTION;
                ex.errorCode = tempEx.ErrorCode;
            }
            else if (exc is OperationNotSupportedException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.NOTSUPPORTED;
            }
            else if (exc is StreamAlreadyLockedException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.STREAM_ALREADY_LOCKED;
            }
            else if (exc is StreamCloseException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.STREAM_CLOSED;
            }
            else if (exc is StreamInvalidLockException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.STREAM_INVALID_LOCK;
            }
            else if (exc is StreamNotFoundException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.STREAM_NOT_FOUND;
            }
            else if (exc is StreamException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.STREAM_EXC;
            }
            else if (exc is TypeIndexNotDefined)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.TYPE_INDEX_NOT_FOUND;
            }
            else if (exc is AttributeIndexNotDefined)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.ATTRIBUTE_INDEX_NOT_FOUND;
            }
            else if (exc is StateTransferInProgressException)
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.STATE_TRANSFER_EXCEPTION;
            }
            else
            {
                ex.type = Alachisoft.NCache.Common.Protobuf.Exception.Type.GENERALFAILURE;
            }

            Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
            response.requestId = requestId;

            response.commandID    = commandID;
            response.exception    = ex;
            response.responseType = Alachisoft.NCache.Common.Protobuf.Response.Type.EXCEPTION;

            return(SerializeResponse(response));
        }