Exemple #1
0
 public override string ToString()
 {
     return(String.Format(
                "{0} (0x{1:x}) {2} {3}\n{4}",
                GetType(), HResult, Message, InnerException == null ? "" : InnerException.ToString(),
                StackTrace != null ? StackTrace : ""));
 }
        public override string ToString()
        {
            string s = GetType().ToString() + ": " + Message;

            if (_fileName != null && _fileName.Length != 0)
            {
                s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName);
            }

            if (InnerException != null)
            {
                s = s + InnerExceptionPrefix + InnerException.ToString();
            }

            if (StackTrace != null)
            {
                s += Environment.NewLine + StackTrace;
            }

            if (_fusionLog != null)
            {
                s ??= " ";
                s += Environment.NewLine;
                s += Environment.NewLine;
                s += _fusionLog;
            }

            return(s);
        }
        public object Clone()
        {
            var retEx = new LogException()
            {
                ErrorCode     = this.ErrorCode,
                ExceptionType = this.ExceptionType,
                HelpLink      = this.HelpLink,
                Message       = this.Message,
                Source        = this.Source,
                StackTrace    = this.StackTrace,
                TargetSite    = this.TargetSite
            };

            if (InnerException != null)
            {
                retEx.InnerException = (LogException)InnerException.Clone();
            }
            if (Data != null && Data.Count > 0)
            {
                foreach (var item in Data)
                {
                    retEx.Data.Add(item.Clone() as Property);
                }
            }

            if (Properties != null && Properties.Count > 0)
            {
                foreach (var prop in Properties)
                {
                    retEx.Properties.Add(prop.Clone() as Property);
                }
            }
            return(retEx);
        }
Exemple #4
0
        public void ExecuteAsync()
        {
            var executor = ServiceProvider.GetRequiredService <IBackgroundJobExecuter>();

            Should.Throw <ScorpioException>(() => executor.ExecuteAsync(new JobExecutionContext(ServiceProvider, typeof(BackgroundJob <int>), 1)));
            Should.Throw <ScorpioException>(() => executor.ExecuteAsync(new JobExecutionContext(ServiceProvider, typeof(IServiceProvider), 1)));
            Should.NotThrow(async() =>
            {
                await executor.ExecuteAsync(new JobExecutionContext(ServiceProvider, typeof(BackgroundJob <string>), "Test"));
                ServiceProvider.GetRequiredService <BackgroundJob <string> >().ReceivedWithAnyArgs(1).Execute(Arg.Any <string>());
            });
            Should.NotThrow(async() =>
            {
                await executor.ExecuteAsync(new JobExecutionContext(ServiceProvider, typeof(AsyncBackgroundJob <string>), "Test"));
                await ServiceProvider.GetRequiredService <AsyncBackgroundJob <string> >().ReceivedWithAnyArgs(1).ExecuteAsync(Arg.Any <string>());
            });
            Should.Throw <BackgroundJobExecutionException>(async() =>
            {
                var job = ServiceProvider.GetRequiredService <BackgroundJob <string> >();
#pragma warning disable S3626 // Jump statements should not be redundant
                job.WhenForAnyArgs(e => e.Execute(Arg.Any <string>())).Do(x => throw new NotImplementedException());
#pragma warning restore S3626 // Jump statements should not be redundant
                await executor.ExecuteAsync(new JobExecutionContext(ServiceProvider, typeof(BackgroundJob <string>), "Test"));
            }).InnerException.ShouldBeOfType <TargetInvocationException>().InnerException.ShouldBeOfType <NotImplementedException>();
        }
Exemple #5
0
        /// <summary>
        /// Generates an exception depending on the code of the error.
        /// </summary>
        /// <returns>An exception which can be thrown.</returns>
        public Exception GetException()
        {
            Exception exception;

            switch (Code)
            {
            /* Argument-Errors */
            case 0x30000010:
                exception = new ArgumentNullException(Message, InnerException?.GetException());
                break;

            case 0x30000011:
                exception = new ArgumentException(Message, InnerException?.GetException());
                break;

            case 0x30000012:
                exception = new ArgumentNullException(Data["PropertyName"], Message);
                break;

            /* Query-Errors */
            case 0x30000030:
                exception = new ConstraintException(Message, InnerException?.GetException());
                break;

            case 0x30000031:
            /* PasswordUpdate-Errors */
            case 0x000000A0:
                exception = new ObjectNotFoundException(Message, InnerException?.GetException());
                break;

            /* Security-Errors */
            case 0x30000070:
            case 0x30000071:
            case 0x30000072:
                exception = new SecurityException(Message, InnerException?.GetException());
                break;

            /* Login-Errors */
            case 0x30000080:
                exception = new InvalidCredentialException(Message, InnerException?.GetException());
                break;

            /* Registration-Errors */
            case 0x30000090:
                exception = new ArgumentException(Message, InnerException?.GetException());
                break;

            default:
                exception = new Exception(Message, InnerException?.GetException());
                break;
            }

            foreach (KeyValuePair <string, string> entry in Data)
            {
                exception.Data.Add(entry.Key, entry.Value);
            }

            exception.Data.Add("ErrorCode", Code);
            return(exception);
        }
        public override string ToString()
        {
            string s = GetType().ToString() + ": " + Message;

            if (!string.IsNullOrEmpty(FileName))
            {
                s += Environment.NewLineConst + SR.Format(SR.IO_FileName_Name, FileName);
            }

            if (InnerException != null)
            {
                s += Environment.NewLineConst + InnerExceptionPrefix + InnerException.ToString();
            }

            if (StackTrace != null)
            {
                s += Environment.NewLineConst + StackTrace;
            }

            if (FusionLog != null)
            {
                s ??= " ";
                s += Environment.NewLineConst + Environment.NewLineConst + FusionLog;
            }

            return(s);
        }
Exemple #7
0
        /// <summary>
        /// Creates and returns a string representation of the current <see cref="EDBTransactionBusyException"/>.
        /// </summary>
        /// <returns>A string representation of the current <see cref="EDBTransactionBusyException"/>.</returns>
        /// <remarks>See https://msdn.microsoft.com/en-us/library/system.exception.tostring(v=vs.100).aspx for the standard
        /// .NET implementation of the System.Exception.ToString() Method.</remarks>
        public override string ToString()
        {
            string ReturnValue;
            string StackTraceStr;

            // Start the ToString() return value as .NET does for the System.Exception.ToString() Method...
            ReturnValue = GetType().FullName + ": " + Message + Environment.NewLine;

            // ...then add our "special information"...
            if (NestedTransactionProblemDetails != null)
            {
                ReturnValue += "  --> " + NestedTransactionProblemDetails + Environment.NewLine;
            }

            // ...and end the ToString() return value as .NET does for the System.Exception.ToString() Method.
            if (InnerException != null)
            {
                ReturnValue += InnerException.ToString() + Environment.NewLine;
            }

            StackTraceStr = Environment.StackTrace;

            if (!String.IsNullOrEmpty(StackTraceStr))
            {
                ReturnValue += "Server stack trace:" + Environment.StackTrace + Environment.NewLine;
            }

            return(ReturnValue);
        }
Exemple #8
0
        public override string ToString()
        {
            string s = GetType().ToString() + ": " + Message;

            if (FileName != null && FileName.Length != 0)
            {
                s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, FileName);
            }

            if (InnerException != null)
            {
                s = s + " ---> " + InnerException.ToString();
            }

            if (StackTrace != null)
            {
                s += Environment.NewLine + StackTrace;
            }

            if (FusionLog != null)
            {
                if (s == null)
                {
                    s = " ";
                }
                s += Environment.NewLine;
                s += Environment.NewLine;
                s += FusionLog;
            }

            return(s);
        }
        public override String ToString()
        {
            String s = GetType().FullName + ": " + Message;

            if (_fileName != null && _fileName.Length != 0)
                s += Environment.NewLine + Environment.GetResourceString("IO.FileName_Name", _fileName);
            
            if (InnerException != null)
                s = s + " ---> " + InnerException.ToString();

            if (StackTrace != null)
                s += Environment.NewLine + StackTrace;

#if FEATURE_FUSION
            try
            {
                if(FusionLog!=null)
                {
                    if (s==null)
                        s=" ";
                    s+=Environment.NewLine;
                    s+=Environment.NewLine;
                    s+=FusionLog;
                }
            }
            catch(SecurityException)
            {
            
            }
#endif // FEATURE_FUSION

            return s;
        }
Exemple #10
0
        public string ToString(FileNameType fileNameType = FileNameType.Relative, bool printStackTrace = false)
        {
            string fileName = fileNameType == FileNameType.None
                ? ""
                : fileNameType == FileNameType.Full
                ? CodeFile.FullName
                : fileNameType == FileNameType.Relative
                ? CodeFile.RelativeName
                : CodeFile.Name;

            string fileNameString = !string.IsNullOrEmpty(fileName)
                ? $@" in ""{fileName}"""
                : "";
            string patternString = CodeFile.IsPattern ? "Pattern " : "";

            string exceptionString = printStackTrace
                ? InnerException?.FormatExceptionMessage() ?? Message
                : Message;

            if (string.IsNullOrEmpty(exceptionString))
            {
                exceptionString = InnerException?.FormatExceptionMessage();
            }

            if (!string.IsNullOrEmpty(exceptionString))
            {
                exceptionString = $": {exceptionString}";
            }

            return($"{patternString}{ExceptionType}{fileNameString}{exceptionString}.");
        }
Exemple #11
0
        /// <inheritdoc/>
        public override string ToString()
        {
            string s = GetType().FullName + ": " + Message;

            if (_columnName != null && _columnName.Length != 0)
            {
                s += Environment.NewLine + "ColumnName: " + _columnName;
                if (!string.IsNullOrWhiteSpace(_tableName))
                {
                    s += Environment.NewLine + "TableName: " + _tableName;
                }
            }

            if (InnerException != null)
            {
                s = s + " ---> " + InnerException.ToString();
            }

            if (StackTrace != null)
            {
                s += Environment.NewLine + StackTrace;
            }

            return(s);
        }
Exemple #12
0
        //************************************************************************
        /// <summary>
        /// メッセージ文字列を返す。
        /// </summary>
        //************************************************************************
        public override string ToString()
        {
            if (ApplicationMessage != null)
            {
                // 全メッセージ文字列を連結
                StringBuilder builder = new StringBuilder(ApplicationMessage.ToString());

                // メッセージがエラー以外の場合は簡略化する
                if (ApplicationMessage.MessageCd.Length >= 1 && ApplicationMessage.MessageCd[0] != 'E')
                {
                    if (InnerException != null)
                    {
                        builder.AppendLine().Append(InnerException.GetType().FullName)
                        .Append(": ").Append(InnerException.Message);
                    }
                }
                else
                {
                    builder.AppendLine().Append(base.ToString());
                }

                return(builder.ToString());
            }
            else
            {
                return(base.ToString());
            }
        }
        /// <summary>
        /// Returns a string representation of the exception
        /// </summary>
        /// <returns>The exception as a string</returns>
        //  Revision History
        //  MM/DD/YY who Version Issue# Description
        //  -------- --- ------- ------ ---------------------------------------
        //  02/06/12 RCG 2.70.64 N/A    Created

        public override string ToString()
        {
            string ExceptionString = this.GetType().ToString() + ": ";

            if (Message != null)
            {
                ExceptionString += Message + " ";
            }

            if (m_ExceptionResponse != null)
            {
                ExceptionString += "Exception Response. Service Error: " + EnumDescriptionRetriever.RetrieveDescription(m_ExceptionResponse.ServiceError)
                                   + " Stat Error: " + EnumDescriptionRetriever.RetrieveDescription(m_ExceptionResponse.StateError) + "\r\n";
            }

            if (m_ConfirmedServiceError != null)
            {
                ExceptionString += "Confirmed Service Error: " + m_ConfirmedServiceError.ServiceError.ToDescription();
            }

            if (InnerException != null)
            {
                ExceptionString += "Inner Exception: " + InnerException.ToString() + "\r\n";
            }

            ExceptionString += "Stack Trace: " + StackTrace;

            return(ExceptionString);
        }
Exemple #14
0
 public override string ToString()
 {
     if (null != InnerException)
     {
         return(InnerException.ToString());
     }
     return(base.ToString());
 }
Exemple #15
0
 public override string ToString()
 {
     if (this.TwitterErrorCode.HasValue)
     {
         return(this.TwitterErrorCode.Value + ": " + Message);
     }
     return(InnerException.ToString());
 }
Exemple #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="aceGeneralException"/> class.
        /// </summary>
        /// <param name="__message">The message.</param>
        /// <param name="__innerException">The inner exception.</param>
        public aceGeneralException(String __message = "", Exception __innerException = null, Object __callerInstane = null, String __title = "", Int32 stacks = 0) : base(__message, __innerException)
        {
            Int32 stackSkip = 1 + stacks;


            while (__innerException != null)
            {
                __innerException = __innerException.InnerException as aceGeneralException;
                stackSkip++;
            }


            _stackTrace = new StackTrace(true);
            //_stackFrame = _stackTrace.GetFrame(0);
            _stackFrame = getFirstFrameWithSource(_stackTrace, stackSkip);
            _message    = __message;
            title       = __title;

            if (_stackTrace == null)
            {
                _stackTraceText = Environment.StackTrace;
            }
            else
            {
                _stackTraceText = _stackTrace.ToString();
            }

            callInfo = callerInfo.getCallerInfo(_stackFrame, true);
            info     = callInfo.AppendDataFields(info);
            info     = callInfo.AppendDataFieldsOfMethod(info);


            if (InnerException != null)
            {
                if (imbSciStringExtensions.isNullOrEmptyString(__message))
                {
                    _message += Environment.NewLine + InnerException.Message;
                }
                if (imbSciStringExtensions.isNullOrEmptyString(title))
                {
                    title = "Exception: " + InnerException.GetType().Name + " in " + callInfo.className;
                }
            }
            var ex = InnerException;

            imbSCI.Core.reporting.render.builders.builderForMarkdown md = new builderForMarkdown();
            Int32 c = 1;

            while (ex != null)
            {
                ex.reportSummary(md, "Inner exception [" + c + "]");
                ex = ex.InnerException;
                c++;
            }
            _message = _message.addLine(md.ContentToString());

            HelpLink = Directory.GetCurrentDirectory() + "\\diagnostics\\index.html";
        }
Exemple #17
0
 private XElement GetXElement()
 => new XElement
 (
     "Exception",
     new XElement(nameof(Message), Message),
     new XElement(nameof(Source), Source),
     new XElement(nameof(Helplink), Helplink),
     new XElement(nameof(StackTrace), StackTrace),
     InnerException?.GetXElement()
 );
Exemple #18
0
        public void FilterFactoryThrows()
        {
            _filterFactories[0] = provider => throw new NotSupportedException("oops!");

            var ex = Assert.Throws <InvalidOperationException>(() => _sut.CreateHandler(_service.Object, _context.Object));

            Console.WriteLine(ex);
            ex !.InnerException.ShouldBeOfType <NotSupportedException>();
            ex.InnerException.Message.ShouldContain("oops!");
        }
Exemple #19
0
        /// <summary>
        ///     Puke original exception (only with Message, HelpLink and Source properties, other properties are has not accessible
        ///     setters) with inner exceptions
        /// </summary>
        /// <returns>Exception</returns>
        public Exception PukeException()
        {
            var exception = InnerException != null
                ? new Exception(Message, InnerException.PukeException())
                : new Exception(Message);

            exception.HelpLink = HelpLink;
            exception.Source   = Source;
            return(exception);
        }
 public override string ToString()
 {
     if (InnerException != null)
     {
         return(InnerException.ToString());
     }
     else
     {
         return(String.Format("Line: [{0}] Query: " + Query, Line));
     }
 }
        public override string ToString()
        {
            return(string.Format(@"{0}
{1}
{2}
innerException:
{3}
{2}
server Exception: 
{4}", base.Message, StackTrace, new string('-', 80), InnerException?.OutlineException(), serverException));
        }
        /// <summary>
        /// Gibt einen <see cref="T:System.String"/> zurück, der das aktuelle <see cref="T:System.Object"/> darstellt.
        /// </summary>
        /// <returns>
        /// Ein <see cref="T:System.String"/>, der das aktuelle <see cref="T:System.Object"/> darstellt.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override string ToString()
        {
            return($@"{ExceptionType}: {Message}
{StackTrace}
Exception-Data:
{string.Join(@"
", from t in collectedInformation select $"{t.Key}: {t.Value}")}
{new string('-', 80)}
{((InnerException != null) ? string.Join($@"
{new string('-', 80)}", InnerException?.Select(n => n.ToString()) ?? new string[] {""}) : "")}");
        }
Exemple #23
0
        public override string ToString()
        {
            string text = $"{Message}\r\nContent:\r\n\t\t{Content.Replace("\r\n", "\r\n\t\t\t")}\r\n\r\n";

            if (InnerException != null)
            {
                return(text + "Inner Exception:\r\n" + InnerException.ToString().Replace("\r\n", "\r\n\t\t\t"));
            }

            return(text);
        }
        /// <summary>
        /// Creates and returns a string representation of the current exception.
        /// </summary>
        /// <returns>
        /// A string representation of the current exception.
        /// </returns>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder(base.ToString());

            if (InnerException != null)
            {
                builder.AppendLine(string.Format("Inner Exception ({0}): ", InnerException.GetType()));
                builder.AppendLine(InnerException.ToString());
            }
            return(builder.ToString());
        }
Exemple #25
0
        /// <summary>
        /// Obtém os detalhes do erro em formato string
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        public override string ToString()
        {
            var exMsg    = (Message != null) ? "MESSAGE = " + Message.ToString() : string.Empty;
            var exInner  = (InnerException != null) ? " | INNER: " + InnerException.ToString() : string.Empty;
            var exStack  = (StackTrace != null) ? " | STACK: " + StackTrace.ToString() : string.Empty;
            var exSource = (StackTrace != null) ? " | SOURCE: " + Source.ToString() : string.Empty;

            var msg = string.Format("[ {0} {1} {3} {2} ]", exMsg, exInner, exStack, exSource);

            return(msg);
        }
        public override string ToString()
        {
            string ret = "<Exception exceptionCode='" + ExceptionCode
                         + (!string.IsNullOrEmpty(Locator) ? "' locator='" + Locator : "")
                         + (!string.IsNullOrEmpty(Message) ? "'><ExceptionText>" + Utils.FormatStringForXml(Message) + "</ExceptionText>\n</Exception>" : "'/>");

            if (InnerException != null)
            {
                ret = InnerException.ToString() + "\n" + ret;
            }
            return(ret);
        }
Exemple #27
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Type.GetHashCode();

                hashCode = (hashCode * 397) ^ Message.GetHashCode();
                hashCode = (hashCode * 397) ^ StackTrace.GetHashCode();
                hashCode = (hashCode * 397) ^ (InnerException != null ? InnerException.GetHashCode() : 0);

                return(hashCode);
            }
        }
        /// <summary>
        /// Checks for specific error types
        /// </summary>
        /// <param name="exceptionTypes">the desired types</param>
        /// <returns>a value indicating whether the specified type was found</returns>
        public bool ContainsType(params string[] exceptionTypes)
        {
            bool retVal =
                exceptionTypes.Select(
                    t => ExceptionType != null && ExceptionType.Contains(t)).Any(n => n);

            if (!retVal && InnerException != null)
            {
                retVal |= InnerException.Any(n => n.ContainsType(exceptionTypes));
            }

            return(retVal);
        }
Exemple #29
0
        public override string ToString()
        {
            string output = type.ToString();

            if (Message != "")
            {
                output += "\n" + Message;
            }
            if (InnerException != null)
            {
                output += "\n" + InnerException.ToString();
            }
            return(output);
        }
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendFormat("DbCommandExecutionException: {0}\r\ninnerException:\r\n{1}\r\ndatabase: {2}\r\ncommandTimeout: {3}\r\ncommandText: {4}",
                            Message,
                            InnerException.ToLogString(),
                            _database,
                            _commandTimeout,
                            _commandText);
            var s = sb.ToString();

            return(s);
        }