本文整理汇总了C#中System.Exception.?.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.?.ToString方法的具体用法?C# Exception.?.ToString怎么用?C# Exception.?.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.?.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JSONDiffRow
public JSONDiffRow(JSONProblem problemType, JSONWarnLevel warnLevel, string message, Exception ex = null)
{
ProblemType = problemType;
WarnLevel = warnLevel;
Message = message;
Exception = ex?.ToString();
}
示例2: Trace
public void Trace(string source, string message, Exception exception)
{
if (this.IsTraceEnabled)
{
this.Trace(source, message, exception?.ToString() ?? string.Empty);
}
}
示例3: Debug
public void Debug(string source, string message, Exception exception)
{
if (this.IsDebugEnabled)
{
this.Debug(source, message, exception?.ToString() ?? string.Empty);
}
}
示例4: MoveResult
public MoveResult(string sourceKey, string destKey, Exception e, string errorMsg = null)
: this(sourceKey, destKey) {
Contract.NotNull(e, nameof(e));
this.SourceKey = sourceKey;
this.DestKey = destKey;
this.Exception = e;
this.errorMsg = errorMsg ?? e?.ToString();
this.Success = false;
}
示例5: Log
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
{
string message = String.Format(CultureInfo.InvariantCulture,
"Provider: {0}" + Environment.NewLine +
"Log level: {1}" + Environment.NewLine +
"Event id: {2}" + Environment.NewLine +
"Exception: {3}" + Environment.NewLine +
"Message: {4}", _name, logLevel, eventId, exception?.ToString(), formatter(state, exception));
_factory._log.AppendLine(message);
}
示例6: CreateLogEntry
protected LogEntry CreateLogEntry(string message, LogOperations LogOperation, Exception ex = null)
{
var result = new LogEntry(Request.UserHostAddress,
User.Identity.Name,
message,
LogOperation.ToString(),
ex?.ToString());
return result;
}
示例7: CallLogger
private void CallLogger(LogLevel level, object message, Exception exception = null)
{
switch (level)
{
case LogLevel.Debug:
Trace.WriteLine($"DEBUG - {message}, {exception?.ToString() ?? "(null)"}");
if (logger.IsDebugEnabled)
{
logger.Debug(message, exception);
}
return;
case LogLevel.Error:
Trace.WriteLine($"ERROR - {message}, {exception?.ToString() ?? "(null)"}");
if (logger.IsErrorEnabled)
{
logger.Error(message, exception);
}
return;
case LogLevel.Fatal:
Trace.WriteLine($"FATAL - {message}, {exception?.ToString() ?? "(null)"}");
if (logger.IsFatalEnabled)
{
logger.Fatal(message, exception);
}
return;
case LogLevel.Info:
Trace.WriteLine($"INFO - {message}, {exception?.ToString() ?? "(null)"}");
if (logger.IsInfoEnabled)
{
logger.Info(message, exception);
}
return;
default:
Trace.WriteLine($"WARN - {message}, {exception?.ToString() ?? "(null)"}");
if (logger.IsWarnEnabled)
{
logger.Warn(message, exception);
}
return;
}
}
示例8: ErrorResponse
private IActionResult ErrorResponse(int error, string serviceId = null, Exception ex = null)
{
var s = errors[error];
return JilJsonResult.CreateWithStatusCode(new
{
error = new
{
code = error,
message = s.Message,
exception = ex?.ToString()
}
}, s.StatusCode);
}
示例9: Write
async Task Write(string phase, object e, Exception ex = null)
{
var s = new XmlSerializer(e.GetType());
var w = new StringWriter();
s.Serialize(w, e);
_context.Entries.Create(new LogEntryData
{
LoggedAt = _clock.Time,
UserId = _authenticator.UserId,
Text = phase + " " + e,
Error = ex?.ToString(),
Xml = w.ToString()
});
await _context.SaveAsync();
}
示例10: Warning
internal void Warning(string message, Exception exception)
{
if (IsWarningEnabled)
Warning(message, exception?.ToString() ?? string.Empty);
}
示例11: Info
public void Info(string source, string message, Exception exception)
{
if (this.IsInfoEnabled)
{
this.Info(source, message, exception?.ToString() ?? string.Empty);
}
}
示例12: ShowFullError
/// <summary>
/// Показать ошибку на экране.
/// </summary>
/// <param name="ex">Ошибка.</param>
/// <returns>Результат.</returns>
public static async Task ShowFullError(Exception ex)
{
var dialog = new ErrorInfoDialog();
dialog.Error = ex?.ToString() ?? "";
await dialog.ShowAsync();
}
示例13: Error
public void Error(string source, string message, Exception exception)
{
if (this.IsErrorEnabled)
{
this.Error(source, message, exception?.ToString() ?? string.Empty);
}
}
示例14: LogError
/// <summary>
/// Logs the error.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="ex">Ex.</param>
/// <param name="message">Message.</param>
public void LogError(object sender, Exception ex = null, string message = null)
{
Debug.WriteLine(string.Format("ERROR {0}: {1}{2}{3}", sender?.GetType()?.Name, message, Environment.NewLine, ex?.ToString()));
}
示例15: Error
public void Error(string message, Exception exception, string scope) => this.Error(message, exception?.ToString() ?? string.Empty, scope);