public static Class Exceptionextend
{
<summary>
Use reflection to determine whether an object contains a property
</summary>
<param name= "instance" >object</param>
<param name= "PropertyName" > Properties to be judged </param>
<returns> whether it contains </returns>
public static bool Containproperty (This object instance, string propertyname)
{
if (instance! = null &&!string. IsNullOrEmpty (PropertyName))
{
PropertyInfo _findedpropertyinfo = instance. GetType (). GetProperty (PropertyName);
Return (_findedpropertyinfo! = null);
}
return false;
}
<summary>
Get error message
</summary>
<param name= "Ex" ></param>
<returns></returns>
public static string Getexceptionmessage (Exception ex)
{
Return Containproperty (ex, "innerexception") = = true? Ex. InnerException.Message:ex. Message;
}
}
Determine if there are innerexception properties in the exception class