本文整理汇总了C#中ExceptionType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ExceptionType.ToString方法的具体用法?C# ExceptionType.ToString怎么用?C# ExceptionType.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExceptionType
的用法示例。
在下文中一共展示了ExceptionType.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomException
/// <summary>
///
/// </summary>
/// <param name="exType">Type of ExceptionType.</param>
/// <param name="message">The error message for this exception.</param>
/// <param name="innerException">The inner exception that is wrapped in this exception.</param>
public CustomException(ExceptionType exType, string message, System.Exception innerException)
: base(message, innerException)
{
//this.CustomMessage = rm.GetString(exType.ToString());
this.CustomMessage = ExpResources.ExpResources.ResourceManager.GetString(exType.ToString()) ?? "[[" + exType.ToString() + "]]";
this.ExceptionType = exType.ToString();
}
示例2: QStrategyException
public QStrategyException(string message, Exception innerException, ExceptionType exceptionType, string sourceLocation)
: base(message, innerException)
{
this.exceptionType = exceptionType;
this.sourceLocation = sourceLocation;
string messageDetail = message;
message = exceptionType.ToString();
if (innerException != null)
{
while (innerException.InnerException != null)
{
innerException = innerException.InnerException;
}
message = innerException.Message;
messageDetail = innerException.StackTrace;
}
string messageLog = string.Format("ExceptionType: {0}, Source:{1}, Exception:{2} MessageDetails: {3}", ExceptionType.ToString(), sourceLocation, message, messageDetail);
LogUtil.WriteLog(LogLevel.ERROR, messageLog);
}
示例3: HandleException
private static void HandleException(ExceptionType exceptionType, Exception exception, string source)
{
using (var eventLog = new EventLog())
{
if (!System.Diagnostics.EventLog.SourceExists(source))
{
System.Diagnostics.EventLog.CreateEventSource(source, "Application");
}
eventLog.Source = source;
eventLog.Log = "Application";
StringBuilder message = new StringBuilder();
message.AppendLine("A " + source + " " + exceptionType.ToString() + " occurred with the following details:");
message.AppendLine();
message.AppendLine(exception.Message);
if (exception.InnerException != null)
{
message.AppendLine();
message.AppendLine("InnerException:");
message.AppendLine(exception.InnerException.ToString());
}
message.AppendLine();
message.AppendLine("StackTrace:");
message.AppendLine(exception.StackTrace);
eventLog.WriteEntry(message.ToString(), System.Diagnostics.EventLogEntryType.Error);
StringBuilder returnMessage = new StringBuilder();
returnMessage.AppendLine("Exception:");
returnMessage.AppendLine(exception.Message);
if (exception.InnerException != null)
{
returnMessage.AppendLine();
returnMessage.AppendLine("Inner Exception:");
returnMessage.AppendLine(exception.InnerException.Message);
}
}
}
示例4: TranslationException
public TranslationException(ExceptionType eType, string message)
: base(eType.ToString() + ": " + message) {
}
示例5: CheckExceptionType
private void CheckExceptionType(ExceptionType type, Action action)
{
try {
action.Invoke();
}
catch (ErrReportException e) {
if (type == ExceptionType.Regular) {
return;
}
Assert.Fail("Got and exption type {0} while expecting ", e.GetType().Name, type.ToString());
}
catch (FaultException<ErrReport> e) {
if (type == ExceptionType.Fault) {
return;
}
Assert.Fail("Got and exption type {0} while expecting ", e.GetType().Name, type.ToString());
}
catch (Exception e) {
Assert.Fail("Got and exption type {0} while expecting ", e.GetType().Name, type.ToString());
}
}