This exception is raised if an operation call on a server raises an unknown exception. For example, for C++, this exception is raised if the server throws a C++ exception that is not directly or indirectly derived from Ice::LocalException or Ice::UserException.
Inheritance: LocalException
Example #1
0
        protected void OpenCallback(string projectToken, Gs2Exception e)
        {
            if (projectToken == null && e == null)
            {
                // 応答からプロジェクトトークンが取得できなかった場合
                // そのまま Idle 状態に遷移するので、 Open 失敗の後始末が必要な場合は派生クラスで対応が必要

                e = new UnknownException("No project token returned.");
            }

            using (var scopedLock = new NonreentrantLock.ScopedLock(_lock))
            {
                if (e == null)
                {
                    ProjectToken = projectToken;
                    _state       = State.Available;

                    CompleteOpenTasks(new AsyncResult <OpenResult>(new OpenResult(), null));
                }
                else
                {
                    // キャンセルがかけられていれば、実際の失敗の内容が何であれ、キャンセルによる失敗として扱う
                    if (_state == State.CancellingOpen)
                    {
                        e = new SessionNotOpenException("Cancelled.");
                    }

                    _state = State.Idle;

                    // TODO: Open と Close のコールバックの順番の保証
                    CompleteOpenTasks(new AsyncResult <OpenResult>(null, e));
                    CompleteCloseTasks();
                }
            }
        }
Example #2
0
        public Gs2WebSocketResponse(string message) : base(message)
        {
            try
            {
                var gs2Message = Gs2Message.FromDict(JsonMapper.ToObject(message));
                Body = gs2Message.body;

                var errorMessage = "";
                if (gs2Message.status != 200)
                {
                    var error = GeneralError.FromDict(gs2Message.body);
                    if (error != null)
                    {
                        errorMessage = error.Message;
                    }
                    else
                    {
                        errorMessage = message;
                    }
                }

                Error            = ExtractError(errorMessage, gs2Message.status ?? 0);
                Gs2SessionTaskId = new Gs2SessionTaskId(gs2Message.requestId);
            }
            catch (System.Exception)
            {
                Error            = new UnknownException("JSON parsing error: \n" + message);
                Gs2SessionTaskId = Gs2SessionTaskId.InvalidId;
            }
        }
        public bool TryHandle(
            Exception operationException,
            out Exception generatedException,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            generatedException = null;
            ResponseError payload = null;

            switch (operationException)
            {
            case OperationCanceledException operationCanceledException:
                generatedException = !cancellationToken.IsCancellationRequested
                        ? (Exception) new ConnectionTimeoutException()
                        : operationCanceledException;

                return(true);

            case ConnectivityException connectivityException:
                generatedException = connectivityException;
                return(true);

            case HttpOperationException httpException:
            {
                var context = _httpExceptionContextRetriever.RetrieveContext(httpException);
                if (TryHandleHttpExceptionByStatusCode(context, out generatedException))
                {
                    return(true);
                }

                payload = context.ResponseError;
                if (payload != null)
                {
                    if (TryHandleBusinessExceptionByPayload(payload, out generatedException))
                    {
                        return(true);
                    }
                }

                break;
            }
            }

            generatedException = new UnknownException(operationException, payload);
            return(true);
        }
Example #4
0
        public override void Arrange()
        {
            var actionGenerator =
                new DomainGenerator()
                .With <Action <IList <Exception> > >(
                    // repetition increases likelyhood
                    l => l.Add(null),
                    l => l.Add(null),
                    l => l.Add(null),
                    l => l.Add(null),
                    l =>
            {
                Exception exception = new BusinessException();
                l.Add(exception);
                throw exception;
            },
                    l =>
            {
                Exception exception = new SecurityException();
                l.Add(exception);
                throw exception;
            },
                    l =>
            {
                Exception exception = new UnknownException();
                l.Add(exception);
                throw exception;
            },
                    l =>
            {
                Exception exception = new AnotherUnknownException();
                l.Add(exception);
                throw exception;
            });

            input =
                new DomainGenerator()
                .With <ProcessOneWayRequestsInput>(
                    opt => opt.For(i => i.OneWayRequestsAndHandlers, new OneWayRequestsAndHandlers()))
                .With <ProcessOneWayRequestsInput>(
                    opt => opt.For(i => i.Actions, actionGenerator.Many <Action <IList <Exception> > >(3, 3).ToList()))
                .One <ProcessOneWayRequestsInput>();
        }
        public override void Arrange()
        {
            var actionGenerator =
                new DomainGenerator()
                    .With<Action<IList<Exception>>>(
                        // repetition increases likelyhood
                    l => l.Add(null),
                    l => l.Add(null),
                    l => l.Add(null),
                    l => l.Add(null),
                    l =>
                        {
                            Exception exception = new BusinessException();
                            l.Add(exception);
                            throw exception;
                        },
                    l =>
                        {
                            Exception exception = new SecurityException();
                            l.Add(exception);
                            throw exception;
                        },
                    l =>
                        {
                            Exception exception = new UnknownException();
                            l.Add(exception);
                            throw exception;
                        },
                    l =>
                        {
                            Exception exception = new AnotherUnknownException();
                            l.Add(exception);
                            throw exception;
                        });

            input =
                new DomainGenerator()
                    .With<ProcessOneWayRequestsInput>(
                        opt => opt.For(i => i.OneWayRequestsAndHandlers, new OneWayRequestsAndHandlers()))
                    .With<ProcessOneWayRequestsInput>(
                        opt => opt.For(i => i.Actions, actionGenerator.Many<Action<IList<Exception>>>(3, 3).ToList()))
                    .One<ProcessOneWayRequestsInput>();
        }
            public override void Callback(Gs2RestResponse gs2RestResponse)
            {
                var    error       = gs2RestResponse.Error;
                string accessToken = null;

                if (error == null)
                {
                    try
                    {
                        accessToken = LoginResult.FromDict(JsonMapper.ToObject(gs2RestResponse.Message)).access_token;
                    }
                    catch (System.Exception)
                    {
                        error = new UnknownException("JSON parsing error: \n" + gs2RestResponse.Message);
                    }
                }

                _gs2RestSession.OpenCallback(accessToken, error);
            }
        /// <inheritdoc />
        public Exception CreateException(short code)
        {
            if (_exceptions == null)
            {
                Exception e = new InvalidOperationException("An exception was attempted to be created, but the known list of error codes was null.");
                LogError(e);
                throw e;
            }

            if (!_exceptions.ContainsKey(code))
            {
                Exception e = new UnknownException(code);
                LogError(e);
                throw e;
            }

            Type exceptionType = _exceptions[code];

            if (exceptionType == null)
            {
                Exception e = new InvalidOperationException("An exception was attempted to be created, but the targeted type was null.");
                LogError(e);
                throw e;
            }

            object?exception = Activator.CreateInstance(exceptionType);

            if (exception == null)
            {
                Exception e = new InvalidOperationException("An exception was attempted to be created, but the class couldn't be activated.");
                LogError(e);
                throw e;
            }

            return((Exception)exception);
        }
Example #8
0
 private void exception(Current current)
 {
     if (current.Operation.Equals("ice_ids"))
     {
         throw new TestIntfUserException();
     }
     else if (current.Operation.Equals("requestFailedException"))
     {
         throw new ObjectNotExistException();
     }
     else if (current.Operation.Equals("unknownUserException"))
     {
         var ex = new UnknownUserException();
         ex.Unknown = "reason";
         throw ex;
     }
     else if (current.Operation.Equals("unknownLocalException"))
     {
         var ex = new UnknownLocalException();
         ex.Unknown = "reason";
         throw ex;
     }
     else if (current.Operation.Equals("unknownException"))
     {
         var ex = new UnknownException();
         ex.Unknown = "reason";
         throw ex;
     }
     else if (current.Operation.Equals("userException"))
     {
         throw new TestIntfUserException();
     }
     else if (current.Operation.Equals("localException"))
     {
         var 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 TestIntfUserException(); // Yes, it really is meant to be TestIntfException.
     }
     else if (current.Operation.Equals("intfUserException"))
     {
         throw new TestImpossibleException(); // Yes, it really is meant to be TestImpossibleException.
     }
     else if (current.Operation.Equals("asyncResponse"))
     {
         throw new TestImpossibleException();
     }
     else if (current.Operation.Equals("asyncException"))
     {
         throw new TestImpossibleException();
     }
 }
Example #9
0
        /// <summary>
        /// This method translates an exception from the service layer to an exception for the presentation layer
        /// </summary>
        /// <param name="faultException">The fault exception from the service layer</param>
        /// <returns>Returns the exception for the service fault</returns>            
        protected WebExceptionBase GetWebExceptionFromServiceFault(System.ServiceModel.FaultException faultException)
        {
            int errorCodeInInt;
            WebExceptionBase webException = null;

            if (int.TryParse(faultException.Code.Name, out errorCodeInInt))
            {
                ExceptionErrorCode errorCode = (ExceptionErrorCode)errorCodeInInt;
                if (errorCode != ExceptionErrorCode.UnknownException)
                {
                    webException = new VKeCRM.Framework.Web.Exceptions.BusinessException(errorCode);
                }
                else
                {
                    webException = new UnknownException();
                }
            }
            else
            {
                webException = new UnknownException(faultException);
            }

            return webException;
        }
Example #10
0
        /// <summary>
        /// Returns the proper string to be displayed in the presentation layer when an exception occurs. 
        /// This should be used for all called to the controller where a potential error can occur.
        /// </summary>
        /// <param name="messageToDisplay">Default message to display in presentation layer</param>
        /// <param name="ex">Exception to process</param>
        /// <param name="logger">The specific application logger passing from the inheriting contoller base class</param>
        /// <returns>Returns the message to display</returns>
        //public abstract string ProcessException(string messageToDisplay, System.Exception ex);
        public string ProcessException(string messageToDisplay, Exception ex, Logger logger)
        {
            Exception currentException = ex;

            if (!(currentException is BusinessException))
            {
                if (!(currentException is WebExceptionBase))
                {
                    if (currentException is System.Security.SecurityException)
                    {
                        currentException = new ServiceCommunicationException(ExceptionErrorCode.SecurityException, currentException);
                    }
                    else if (currentException is System.ServiceModel.CommunicationObjectFaultedException)
                    {
                        currentException = new ServiceCommunicationException(ExceptionErrorCode.CommunicationObjectFaultedException, currentException);
                    }
                    else if (currentException is System.ServiceModel.Security.MessageSecurityException)
                    {
                        currentException = new ServiceCommunicationException(ExceptionErrorCode.MessageSecurityException, currentException);
                    }
                    else if (currentException is System.TimeoutException)
                    {
                        currentException = new ServiceCommunicationException(ExceptionErrorCode.TimeoutException, currentException);
                    }
                    else if (currentException is System.ServiceModel.CommunicationException)
                    {
                        currentException = new ServiceCommunicationException(ExceptionErrorCode.CommunicationException, currentException);
                    }
                    else if (currentException is System.ObjectDisposedException)
                    {
                        currentException = new ServiceCommunicationException(ExceptionErrorCode.ObjectDisposedException, currentException);
                    }
                    else
                    {
                        currentException = new UnknownException(currentException);
                    }
                }

                logger.Error(currentException.ToString());
            }

            //Add error code to DisplayMessage
            messageToDisplay = string.Concat(messageToDisplay, string.Format(" (ErrorCode: {0})", (int)((WebExceptionBase)currentException).ErrorCode));

            return messageToDisplay;
        }
Example #11
0
 public static new bool Equals(object a, object b)
 {
     throw UnknownException.Instantiate();
 }