コード例 #1
0
        private void ErrorCallback(List <BvException> known, BvAggregateException unknown)
        {
            if (known != null && known.Count > 0)
            {
                SaveInProgress = false;
                string exceptions = "";

                foreach (Exception e in known)
                {
                    Main.SendChatMessage(e.Message);
                    exceptions += e.ToString();
                }

                Log.TryWriteToLogStart(exceptions);
            }

            if (unknown != null)
            {
                Log.TryWriteToLogStart($"\nSave operation failed.\n{unknown.ToString()}");
                Main.SendChatMessage("Save operation failed.");
                SaveInProgress = false;

                throw unknown;
            }
        }
コード例 #2
0
        /// <summary>
        /// Checks a task queue for invalid tasks and tasks with exceptions, logs and throws exceptions
        /// as needed and rebuilds queue with remaining valid tasks.
        /// </summary>
        private void UpdateRunningTasks()
        {
            Task                 task;
            Queue <Task>         currentTasks      = new Queue <Task>();
            List <Exception>     taskExceptions    = new List <Exception>(); //unknown exceptions
            List <BvException>   knownExceptions   = new List <BvException>();
            BvException          bvException       = null;
            BvAggregateException unknownExceptions = null;

            while (tasksRunning.Count > 0)
            {
                if (tasksRunning.TryDequeue(out task) && task.valid)
                {
                    if (task.Exceptions != null)
                    {
                        if (task.Exceptions.Length > 0)
                        {
                            foreach (Exception exception in task.Exceptions)
                            {
                                if (TryGetBvException(exception, out bvException))
                                {
                                    knownExceptions.Add(bvException);
                                }
                                else
                                {
                                    taskExceptions.Add(exception);
                                }
                            }
                        }
                    }
                    else if (!task.IsComplete)
                    {
                        currentTasks.Enqueue(task);
                    }
                }
            }

            tasksRunning = currentTasks;

            if (taskExceptions.Count > 0)
            {
                unknownExceptions = new BvAggregateException(taskExceptions);
            }

            errorCallback(knownExceptions, unknownExceptions);
        }
コード例 #3
0
        private void ErrorCallback(List <BvException> known, BvAggregateException unknown)
        {
            if ((known != null && known.Count > 0) || unknown != null)
            {
                TryWriteToLogFinish(false);

                if (known != null && known.Count > 0)
                {
                    foreach (Exception e in known)
                    {
                        Main.SendChatMessage(e.Message);
                    }
                }

                if (unknown != null)
                {
                    throw unknown;
                }
            }
        }