public void ToString_should_return_expected_result(
            ServerErrorCategory category,
            int code,
            string message,
            string detailsJson,
            string expectedResult)
        {
            var details    = detailsJson == null ? null : BsonDocument.Parse(detailsJson);
            var writeError = new WriteError(category, code, message, details);

            var result = writeError.ToString();

            result.Should().Be(expectedResult);
        }
Пример #2
0
        ///
        /// ------------------------------------------------------------------------------------------------
        /// Name		HandleUnhandledException
        ///
        /// <summary>	Handles the unhandled exception event and caches an event report which is read
        ///             when the app next launches.
        /// </summary>
        /// <param name="sender">		Event source.</param>
        /// <param name="e">			Exception arguments.</param>
        ///
        /// <remarks>
        /// </remarks>
        /// ------------------------------------------------------------------------------------------------
        ///
        private void HandleUnhandledException(object sender, RaiseThrowableEventArgs e)
        {
            IOException   ioex;
            Exception     ex;
            Task          task;
            ErrorReport   report;
            StringBuilder sb;

            try
            {
                ioex = e.Exception as IOException;
                ex   = e.Exception as Exception;
                if (ioex != null)
                {
                    report = new ErrorReport("Unhandled Native Exception", ioex);
                }
                else if (ex != null)
                {
                    report = new ErrorReport("Unhandled Managed Exception", ex);
                }
                else
                {
                    report = new ErrorReport("Unhandled Unrecognised Exception", e.ToString());
                }
                // Make a record of the state of the data when the error occurred.
                sb = new StringBuilder();
                // sb.AppendLine("Premises Data:");
                //  sb.AppendLine(AppData.PremisesModel.Cache);
                //   sb.AppendLine();
                report.AddFurtherInfo(sb.ToString());
                task = new Task(async delegate { await writingfile(report); });
                task.Start();
                task.Wait(1000);
            }
            catch (Exception WriteError)
            {
                report = new ErrorReport("Error File Creation Exception", WriteError.ToString());
                task   = new Task(async delegate { await writingfile(report); });
                task.Start();
                task.Wait(1000);
                LogTracking.LogTrace(WriteError.ToString());
            }
        }