public static Exception ToEx(this ExceptionEnum type, string message = null) { Exception ex = null; if (!string.IsNullOrEmpty(message)) { ex = new Exception(message); } else { switch (type) { case ExceptionEnum.Sql: ex = new Exception("sql错误"); break; case ExceptionEnum.Illegal: ex = new Exception("非法操作"); break; case ExceptionEnum.Operating: ex = new Exception("操作失败"); break; case ExceptionEnum.NoPermission: ex = new Exception("没有相关权限"); break; case ExceptionEnum.Disable: ex = new Exception("已被禁用"); break; case ExceptionEnum.Parameter: ex = new Exception("参数有误"); break; case ExceptionEnum.LoginOut: ex = new Exception("未登录"); break; case ExceptionEnum.NoModel: ex = new Exception("没有找到相关数据"); break; default: ex = new Exception("未知错误"); break; } } ex.HelpLink = ((int)type).ToString(); return(ex); }
public static IEx CreateException(ExceptionEnum i) { if (i == ExceptionEnum.DatabaseException) { return(new DatabaseException()); } else if (i == ExceptionEnum.FileException) { return(new FileException()); } else { return(new EventViewerException()); } }
public static string Error(ExceptionEnum type, string description = null) { return(JsonConvert.SerializeObject(new ErrorsResult(false, type.ToString(), description))); }
/// <summary> /// /// Description: 抛出异常错误信息 /// Author:Liudpc /// Create Date: 2010/12/15 16:23:44 /// </summary> /// <param name="exc"></param> /// <param name="sMessage"></param> public static void ThrowException(ExceptionEnum exc, string sMessage) { Exception e = new Exception("ExceptionEnum:" + exc.ToString() + ";ExceptionMessage:"+sMessage); throw e; }
public AccountException(ExceptionEnum reason) : base(reason.ToString()) { }
public static BaseErrorException SoftException(ExceptionEnum code, string message, params object[] args) { message = string.Format(message, args); return(new BaseErrorException((int)code, message)); }
public static BaseNormalException UserFriendlyException(ExceptionEnum code, string message) { return(new BaseNormalException((int)code, message)); }
public static BaseErrorException SoftException(ExceptionEnum code, string message) { return(new BaseErrorException((int)code, message)); }
public static FriendlyException FriendlyException(ExceptionEnum code, string message) { return(new FriendlyException((int)code, message)); }
public static AuthenticationException AuthenticationException(ExceptionEnum code, string message) { return(new AuthenticationException((int)code, message)); }
public InvalidArgumentException(string message, string paramName, ExceptionEnum code) : base(message, paramName) { Code = (int)code; }
public static string GetExceptionEnum(this ExceptionEnum value) { return($"#{value.GetHashCode()}# : {value.GetAttribute<DisplayAttribute>().Name}"); }
// processor's exception mechanism private void RaiseException(ExceptionEnum Exception, ExceptionDetailEnum ExceptionDetail) { string exception; string message = string.Empty; if ((Exception == ExceptionEnum.GeneralProtection) && (opMode == OpModeEnum.RealAddressMode)) exception = "SegmentOverrun"; else exception = Exception.ToString(); message = "CPU Exception Occurred!\n\nException #" + ((int)Exception).ToString() + " - " + exception; if (Exception != ExceptionEnum.InvalidOpcode) { if (opMode == OpModeEnum.RealAddressMode) { message += "\n\nCS : IP = " + string.Format("0x{0:X4} : 0x{1:X4}", cs, old_ip); } else if (opMode == OpModeEnum.ProtectedMode) { message += "\n\nCS : EIP = " + string.Format("0x{0:X4} : 0x{1:X8}", cs, old_eip); } } else { switch (opMode) { case OpModeEnum.RealAddressMode: message += String.Format("\n\nOpcode = 0x{0:X2}", GetByte(SegmentEnum.CS, GetInstructionPointer(prefixLength))); message += String.Format("\nCS : IP = 0x{0:X4} : 0x{1:X4}", cs, GetInstructionPointer(prefixLength)); break; case OpModeEnum.ProtectedMode: message += String.Format("\n\nOpcode = 0x{0:X2}", GetByte(SegmentEnum.CS, GetInstructionPointer(prefixLength))); message += String.Format("\nCS : IP = 0x{0:X4} : 0x{1:X8}", cs, GetInstructionPointer(prefixLength)); break; case OpModeEnum.IA32e_CompatibilityMode: break; default: // OpModeEnum.IA32e_64bitMode break; } } if (ExceptionDetail != ExceptionDetailEnum.Null) message += "\n\n\"" + exceptionDetailTable[(int)ExceptionDetail] + "\""; throw new System.Exception(message); }
public AccountException(ExceptionEnum reason) : base(reason.ToString()) { Console.WriteLine(reason.ToString()); }
//Exception public AccountException(ExceptionEnum reason) { this.reason = reason; }