本文整理汇总了C#中System.Exception.GetAllMessages方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.GetAllMessages方法的具体用法?C# Exception.GetAllMessages怎么用?C# Exception.GetAllMessages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.GetAllMessages方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogError
public void LogError(Exception exception) {
LastError = "Error trying to process manifest.";
if (exception == null)
return;
LogMessages.Add(String.Concat(DateTime.UtcNow.ToShortDateString(), " - ", exception.ToString()));
LastError = exception.GetAllMessages();
}
示例2: LogException
public static void LogException(Action<string> logger, Exception e, bool addSystemInfo, string msg, params object[] format)
{
if (!string.IsNullOrEmpty(msg))
{
msg = string.Format(msg, format);
logger(msg);
}
if (e != null)
{
LogStacktrace(logger);
logger("");
logger(e.ToString());
//logger(new StackTrace(e, true));
}
if (addSystemInfo)
{
logger("");
SystemInfoLogger(logger);
}
if (e != null)
{
logger("");
logger(e.GetAllMessages().ToString("\n\t"));
}
var evt = ExceptionRaised;
if (evt != null)
{
evt(msg, e);
}
}
示例3: OnCommandFail
protected override void OnCommandFail(WCell.Util.Commands.CmdTrigger<Squishy.Irc.Commands.IrcCmdArgs> trigger, Exception ex)
{
CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, "Exception Occured: " + ex.InnerException.Message);
foreach (string text in ex.GetAllMessages())
CommandHandler.Msg(Properties.Settings.Default.ErrorChannel, text);
}
示例4: ExtensionMethods_GetAllMessages_WhenUnrollingException_ExpectFullExceptionList
public void ExtensionMethods_GetAllMessages_WhenUnrollingException_ExpectFullExceptionList()
{
//------------Setup for test--------------------------
var innerException = new Exception("Inner Exception");
var ex = new Exception("Test Error", innerException);
const string expected = "Test Error\r\nInner Exception";
//------------Execute Test---------------------------
var result = ex.GetAllMessages();
//------------Assert Results-------------------------
StringAssert.Contains(result, expected);
}
示例5: OnDBError
public static void OnDBError(Exception e, string warning)
{
try
{
// probably a production system - Don't drop.
if (DBErrorHook != null && !DBErrorHook(e))
{
throw e;
}
}
catch (Exception ex)
{
log.ErrorException("", ex);
}
var errMsg = "Database Error occured";
LogUtil.ErrorException(e, false, errMsg);
log.Warn("");
foreach (var msg in e.GetAllMessages())
{
log.Warn(msg);
}
log.Warn("");
log.Warn("Database could not be initialized!");
log.Warn("Re-create Database schema? (y/n)");
log.Warn("WARNING: " + warning);
IsWaiting = true;
bool doDrop;
try
{
doDrop = StringStream.GetBool(Input.Read());
}
catch
{
// no Console available (running Tests etc)
doDrop = true;
}
IsWaiting = false;
if (doDrop)
{
log.Warn("Dropping database schema...");
DropSchema();
log.Warn("Done.");
log.Warn("Re-creating database schema...");
try
{
CreateSchema();
}
catch (Exception ex)
{
// damn it! No console output...
throw new InvalidOperationException("", ex);
}
log.Warn("Done.");
}
else
{
throw new InvalidOperationException("", e);
}
}
示例6: Error
public static void Error(string group, Exception exception)
{
var message = $"[Error Text]{exception.GetAllMessages()}\r\n[Error Full]{exception}";
_logger.Log(group, message);
}