本文整理汇总了C#中Exception类的典型用法代码示例。如果您正苦于以下问题:C# Exception类的具体用法?C# Exception怎么用?C# Exception使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Exception类属于命名空间,在下文中一共展示了Exception类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetPageCompletedEventArgs
/// <summary>
/// Constructor.
/// </summary>
/// <param name="page">The DocumentPage object for the requesed Page.</param>
/// <param name="pageNumber">The page number of the returned page.</param>
/// <param name="error">Error occurred during an asynchronous operation.</param>
/// <param name="cancelled">Whether an asynchronous operation has been cancelled.</param>
/// <param name="userState">Unique identifier for the asynchronous task.</param>
public GetPageCompletedEventArgs(DocumentPage page, int pageNumber, Exception error, bool cancelled, object userState)
:
base(error, cancelled, userState)
{
_page = page;
_pageNumber = pageNumber;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:GetPageCompletedEventArgs.cs
示例2: GridViewUpdatedEventArgs
public GridViewUpdatedEventArgs (int affectedRows, Exception e)
{
this.rowsAffected = affectedRows;
this.e = e;
this.exceptionHandled = false;
this.keepEditMode = false;
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:7,代码来源:GridViewUpdatedEventArgs.cs
示例3: LogException
public static void LogException(string message, Exception ex)
{
var logger = log4net.LogManager.GetLogger(LOGGER_NAME);
if (logger == null)
return;
logger.Error(message, ex);
}
开发者ID:nofuture-git,项目名称:31g,代码行数:7,代码来源:SimpleExample.cs
示例4: ThrowAsync
/// <summary>Throws the exception on the thread pool.</summary>
/// <param name="exception">The exception to propagate.</param>
/// <param name="targetContext">
/// The target context on which to propagate the exception; otherwise, <see langword="null"/> to use the thread
/// pool.
/// </param>
internal static void ThrowAsync(Exception exception, SynchronizationContext targetContext)
{
if (targetContext != null)
{
try
{
targetContext.Post(
state =>
{
throw PrepareExceptionForRethrow((Exception)state);
}, exception);
return;
}
catch (Exception ex)
{
exception = new AggregateException(exception, ex);
}
}
#if NET45PLUS
Task.Run(() =>
{
throw PrepareExceptionForRethrow(exception);
});
#else
ThreadPool.QueueUserWorkItem(state =>
{
throw PrepareExceptionForRethrow((Exception)state);
}, exception);
#endif
}
开发者ID:endo0407,项目名称:IteratorTasks,代码行数:37,代码来源:AsyncServices.cs
示例5: GetPageNumberCompletedEventArgs
/// <summary>
/// Constructor.
/// </summary>
/// <param name="contentPosition">The parameter passed into the GetPageNumberAsync call.</param>
/// <param name="pageNumber">The first page number on which the element appears.</param>
/// <param name="error">Error occurred during an asynchronous operation.</param>
/// <param name="cancelled">Whether an asynchronous operation has been cancelled.</param>
/// <param name="userState">Unique identifier for the asynchronous task.</param>
public GetPageNumberCompletedEventArgs(ContentPosition contentPosition, int pageNumber, Exception error, bool cancelled, object userState)
:
base(error, cancelled, userState)
{
_contentPosition = contentPosition;
_pageNumber = pageNumber;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:GetPageNumberCompletedEventArgs.cs
示例6: JsonException
internal JsonException (ParserToken token,
Exception inner_exception) :
base (String.Format (
"Invalid token '{0}' in input string", token),
inner_exception)
{
}
开发者ID:wids-eria,项目名称:tf_client,代码行数:7,代码来源:JsonException.cs
示例7: LogExceptionsBulkUpload
public static void LogExceptionsBulkUpload(Exception Ex, string Page, string method)
{
string _SchLogs = System.Configuration.ConfigurationSettings.AppSettings["ServiceLogFolder"].ToString() + "Bulk_Exceptions.txt";
StringBuilder _BuilderException = new StringBuilder();
_BuilderException.Append("***********************************" + DateTime.Now.ToString() + "***********************************");
_BuilderException.AppendLine();
_BuilderException.Append(Ex.Message.ToString());
_BuilderException.AppendLine();
_BuilderException.AppendLine();
//page
_BuilderException.Append("Page :" + Page);
_BuilderException.AppendLine();
_BuilderException.AppendLine();
//mehotd
_BuilderException.Append("Method :" + method);
_BuilderException.AppendLine();
if (Ex.InnerException != null)
{
_BuilderException.AppendLine();
_BuilderException.Append(Ex.InnerException.ToString());
_BuilderException.AppendLine();
_BuilderException.Append(Ex.Message.ToString());
_BuilderException.AppendLine();
}
_BuilderException.Append("*****************************************************************************************************");
StreamWriter _Sche_Log = new StreamWriter(_SchLogs, true, Encoding.Default);
_Sche_Log.WriteLine(_BuilderException);
_Sche_Log.Close();
}
开发者ID:AbdulAzizFarooqi,项目名称:VIS_TransLog,代码行数:31,代码来源:Logs.cs
示例8: ExceltoDataView
public DataView ExceltoDataView(string strFilePath)
{
DataView dv;
try
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + strFilePath + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1'");
conn.Open();
object[] CSs0s0001 = new object[4];
CSs0s0001[3] = "TABLE";
DataTable tblSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, CSs0s0001);
string tableName = Convert.ToString(tblSchema.Rows[0]["TABLE_NAME"]);
if (tblSchema.Rows.Count > 1)
{
tableName = "sheet1$";
}
string sql_F = "SELECT * FROM [{0}]";
OleDbDataAdapter adp = new OleDbDataAdapter(string.Format(sql_F, tableName), conn);
DataSet ds = new DataSet();
adp.Fill(ds, "Excel");
dv = ds.Tables[0].DefaultView;
conn.Close();
}
catch (Exception)
{
Exception strEx = new Exception("請確認是否使用模板上傳(上傳的Excel中第一個工作表名稱是否為Sheet1)");
throw strEx;
}
return dv;
}
开发者ID:chanhan,项目名称:Project,代码行数:29,代码来源:WorkFlowCardMakeupList.aspx.cs
示例9: ParseFileException
public ParseFileException(string message, string fileName,
long? lineNumber, Exception causeException)
: base(message, causeException)
{
this.fileName = fileName;
this.lineNumber = lineNumber;
}
开发者ID:syssboxx,项目名称:SchoolAcademy,代码行数:7,代码来源:ParseFileException.cs
示例10: HandleException
private static void HandleException(Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex);
Console.ReadKey();
Environment.Exit(0);
}
开发者ID:allrameest,项目名称:ServiceBusDemo,代码行数:7,代码来源:Program.cs
示例11: ThrowWithData
public void ThrowWithData()
{
Exception e = new Exception(msg1);
e.Data[key1] = val1;
e.Data[key2] = val2;
throw (e);
}
开发者ID:l1183479157,项目名称:coreclr,代码行数:7,代码来源:data_helper.cs
示例12: GetNestedPropertyValue
/// <summary>
/// Retrieves the value of a property. That property can be nested.
/// Each element of the path needs to be a public instance property.
/// </summary>
/// <param name="item">Object that exposes the property</param>
/// <param name="propertyPath">Property path</param>
/// <param name="propertyType">Property type</param>
/// <param name="exception">Potential exception</param>
/// <returns>Property value</returns>
internal static object GetNestedPropertyValue(object item, string propertyPath, Type propertyType, out Exception exception)
{
exception = null;
// if the propertyPath is null or empty, use the
// item directly
if (String.IsNullOrEmpty(propertyPath))
{
return item;
}
string[] propertyNames = propertyPath.Split(PropertyNameSeparator);
for (int i = 0; i < propertyNames.Length; i++)
{
if (item == null)
{
break;
}
Type type = item.GetType();
// if we can't find the property or it is not of the correct type,
// treat it as a null value
PropertyInfo propertyInfo = type.GetProperty(propertyNames[i]);
if (propertyInfo == null)
{
break;
}
if (!propertyInfo.CanRead)
{
exception = new InvalidOperationException(string.Format(
System.Globalization.CultureInfo.InvariantCulture,
CommonResources.PropertyNotReadable,
propertyNames[i],
type.GetTypeName()));
break;
}
if (i == propertyNames.Length - 1)
{
// if the property type did not match, return null
if (propertyInfo.PropertyType != propertyType)
{
break;
}
else
{
return propertyInfo.GetValue(item, null);
}
}
else
{
item = propertyInfo.GetValue(item, null);
}
}
return null;
}
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:69,代码来源:TypeHelper.cs
示例13: OnException
public void OnException(Exception e)
{
if (_errorCallback != null)
_errorCallback(e);
else
Debug.Log(e.Message);
}
开发者ID:JuDelCo,项目名称:Shmup-AAA-plus,代码行数:7,代码来源:LeaderBoardController.cs
示例14: DebugMessage
public void DebugMessage(Exception exception)
{
if (exception == null)
return;
DebugMessage(GetExceptionString(exception));
}
开发者ID:40a,项目名称:PowerShell,代码行数:7,代码来源:Tracing.cs
示例15: Abort
internal virtual void Abort(Exception e)
{
if (GlobalLog.IsEnabled)
{
GlobalLog.Print("CommandStream" + LoggingHash.HashString(this) + "::Abort() - closing control Stream");
}
lock (this)
{
if (_aborted)
return;
_aborted = true;
}
try
{
base.Close(0);
}
finally
{
if (e != null)
{
InvokeRequestCallback(e);
}
else
{
InvokeRequestCallback(null);
}
}
}
开发者ID:naamunds,项目名称:corefx,代码行数:30,代码来源:CommandStream.cs
示例16: addFailure
public virtual void addFailure(Exception targetException)
{
if (targetException is MultipleFailureException)
this.addMultipleFailureException((MultipleFailureException) targetException);
else
this.fNotifier.fireTestFailure(new Failure(this.fDescription, targetException));
}
开发者ID:NALSS,项目名称:SmartDashboard.NET,代码行数:7,代码来源:EachTestNotifier.cs
示例17: AddMessage
protected void AddMessage(string Message, string Type, Exception ex = null)
{
if (Type == "Error")
{
Exceptions.LogException(ex);
if (UserInfo.IsSuperUser)
{
Skin.AddModuleMessage(this, Message, ModuleMessage.ModuleMessageType.RedError);
}
else
{
Skin.AddModuleMessage(this, Localization.GetString("msgError.Text", this.LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
}
}
else if (Type == "Success")
{
Skin.AddModuleMessage(this, Message, ModuleMessage.ModuleMessageType.GreenSuccess);
}
else if (Type == "Warning")
{
Skin.AddModuleMessage(this, Message, ModuleMessage.ModuleMessageType.YellowWarning);
}
else if (Type == "Information")
{
Skin.AddModuleMessage(this, Message, ModuleMessage.ModuleMessageType.BlueInfo);
}
}
开发者ID:wet-boew,项目名称:wet-boew-dotnetnuke,代码行数:27,代码来源:Links.ascx.cs
示例18: InvalidCsvFieldException
/// <summary>
/// 构建一个 InvalidCsvFieldException 对象实例
/// </summary>
/// <param name="properyName">属性名称</param>
/// <param name="fieldName">csv字段名称</param>
/// <param name="fieldValue">csv字段值</param>
/// <param name="innerException">字段赋值失败的实际异常实例</param>
public InvalidCsvFieldException(String properyName, String fieldName, String fieldValue, Exception innerException)
: base(
String.Format("propertyName={0}, fieldName={1}, fieldValue={2}, 无效的 csv 字段配置。", properyName, fieldName,
fieldValue), innerException)
{
}
开发者ID:xclouder,项目名称:godbattle,代码行数:14,代码来源:InvalidCsvFieldException.cs
示例19: CtorTest
public static void CtorTest(Exception expectedException, bool expectedCancelled, object expectedState)
{
var target = new AsyncCompletedEventArgsTests(expectedException, expectedCancelled, expectedState);
Assert.Equal(expectedException, target.Error);
Assert.Equal(expectedCancelled, target.Cancelled);
Assert.Equal(expectedState, target.UserState);
}
开发者ID:er0dr1guez,项目名称:corefx,代码行数:7,代码来源:AsyncCompletedEventArgsTests.cs
示例20: SqlDataSourceStatusEventArgs
public SqlDataSourceStatusEventArgs (DbCommand command, int rowsAffected, Exception exception)
{
this.command = command;
this.rowsAffected = rowsAffected;
this.exception = exception;
this.exceptionHandled = false;
}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:SqlDataSourceStatusEventArgs.cs
注:本文中的Exception类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论