//************************************************************************ /// <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> /// 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"; }
/// <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()); }
private void BuildMessageFromInnerException() { var key = DefaultMessageKey; string[] variables = null; if (InnerException != null) { variables = new[] { InnerException.Message }; var errorCode = MessageManager.GetErrorCode(InnerException.GetType().Name); if (!string.IsNullOrEmpty(errorCode)) { key = new MessageKey(DefaultMessageKey.Type, errorCode); } } RichMessage = MessageManager.GetMessage(key, variables); }