public void ConstructorPassesErrorCodeCorrectly(ErrorCode errorCode) { var exception = new AssemblyToolKernelException(errorCode); Assert.AreEqual(1, exception.Code.Length); Assert.AreEqual(errorCode, exception.Code[0]); Assert.AreEqual(errorCode.GetMessage(), exception.Message); Assert.IsNull(exception.InnerException); }
/// <summary> /// Fires an error occurred event. /// </summary> /// <param name="code">The associated error code.</param> public void RaiseErrorOccurred(ErrorCode code) { if (ErrorOccurred != null) { var position = GetCurrentPosition(); var errorArguments = new ParseErrorEventArgs(code.GetCode(), code.GetMessage(), position); ErrorOccurred(this, errorArguments); } }
/// <summary>生成一个包含错误码的标准返回</summary> /// <param name="errCode">错误码</param> /// <param name="message">错误消息</param> /// <returns></returns> public static IApiResult ErrorBuilder(int errCode, string message = null) { return(new ApiResult { Success = errCode == 0, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode) } }); }
/// <summary>生成一个包含错误码的标准返回</summary> /// <param name="errCode">错误码</param> /// <returns></returns> public IApiResult Error(int errCode) { return(new ApiResult { Success = false, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = ErrorCode.GetMessage(errCode) } }); }
/// <summary> /// 生成一个包含错误码的标准返回 /// </summary> /// <param name="errCode">错误码</param> /// <param name="message">错误消息</param> /// <returns></returns> public static ApiFileResult ErrorResult(int errCode, string message = null) { return(new ApiFileResult { Success = errCode == ErrorCode.Success, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode) } }); }
/// <summary>生成一个包含错误码的标准返回</summary> /// <param name="errCode">错误码</param> /// <param name="message"></param> /// <returns></returns> public IApiResult <TData> Error <TData>(int errCode, string message) { return(new ApiResult <TData> { Success = false, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode) } }); }
/// <summary> /// 生成一个包含错误码的标准返回 /// </summary> /// <param name="errCode">错误码</param> /// <param name="message">错误消息</param> /// <returns></returns> public new static ApiArrayResult <TData> Error(int errCode, string message) { return(new ApiArrayResult <TData> { Success = errCode == ErrorCode.Success, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode) } }); }
/// <summary> /// 生成一个包含错误码的标准返回 /// </summary> /// <param name="errCode">错误码</param> /// <returns></returns> public static ApiValueResult ErrorResult(int errCode) { return(new ApiValueResult { Success = false, Status = new ApiStatusResult { ErrorCode = errCode, ClientMessage = ErrorCode.GetMessage(errCode) } }); }
/// <summary>生成一个包含错误码的标准返回</summary> /// <param name="errCode">错误码</param> /// <param name="message">错误消息</param> /// <param name="innerMessage">内部说明</param> /// <returns></returns> public IApiResult Error(int errCode, string message, string innerMessage) { return(new ApiResult { Success = errCode == 0, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode), InnerMessage = innerMessage } }); }
/// <summary> /// 生成一个包含错误码的标准返回 /// </summary> /// <param name="errCode">错误码</param> /// <param name="message">错误消息</param> /// <param name="innerMessage">内部说明</param> /// <param name="guide">错误指导</param> /// <param name="describe">错误解释</param> /// <returns></returns> public new static ApiArrayResult <TData> Error(int errCode, string message, string innerMessage, string guide, string describe) { return(new ApiArrayResult <TData> { Success = errCode == ErrorCode.Success, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode), InnerMessage = innerMessage, GuideCode = guide, Describe = describe } }); }
/// <summary>生成一个包含错误码的标准返回</summary> /// <param name="errCode">错误码</param> /// <param name="message">错误消息</param> /// <param name="innerMessage">内部说明</param> /// <param name="point">错误点</param> /// <param name="guide">错误指导</param> /// <param name="describe">错误解释</param> /// <returns></returns> public IApiResult <TData> Error <TData>(int errCode, string message, string innerMessage, string point, string guide, string describe) { return(new ApiResult <TData> { Success = errCode == 0, Status = new OperatorStatus { ErrorCode = errCode, ClientMessage = message ?? ErrorCode.GetMessage(errCode), InnerMessage = innerMessage, Point = point, GuideCode = guide, Describe = describe } }); }
public void GetMessageReturnsCorrectMessage(ErrorCode code, string expectedMessage) { Assert.AreEqual(expectedMessage, code.GetMessage()); }
/// <summary> /// Creates a new DOMException. /// </summary> /// <param name="code">The error code.</param> internal DomException(ErrorCode code) : base(code.GetMessage()) { Code = (Int32)code; Name = code.ToString(); }
static int Main(string[] args) { #if DEBUG // Used for debugging within Visual Studio (vshost) args = new string[] { "image.jpg" }; //args = new string[] { "/o", "J", "image.jpg" }; //args = new string[] { "test.txt" }; //args = new string[] { "zero" }; #endif if (args.Length == 0) { // Future reminder: // New buffer in editing mode if no arguments ShowHelp(); return(0); } // Defaults string entry = args[args.Length - 1]; MainApp.BytesPerRow = 0; MainApp.OffsetView = OffsetView.Hex; bool dump = false; for (int i = 0; i < args.Length; ++i) { switch (args[i]) { case "-o": case "/o": switch (args[i + 1][0]) { case 'h': case 'H': MainApp.OffsetView = OffsetView.Hex; break; case 'd': case 'D': MainApp.OffsetView = OffsetView.Dec; break; case 'o': case 'O': MainApp.OffsetView = OffsetView.Oct; break; default: Console.WriteLine( ErrorCode.CLI_InvalidOffsetView .GetMessage(args[i + 1]) ); #if DEBUG Console.ReadLine(); #endif return(ErrorCode.CLI_InvalidOffsetView.ToInt()); } break; case "-w": case "/w": { int b = MainApp.BytesPerRow; if (char.ToLower(args[i + 1][0]) != 'a') // Automatic, in case to overwrite settings { MainApp.BytesPerRow = 0; } else if (!int.TryParse(args[i + 1], out b)) { Console.WriteLine( ErrorCode.CLI_InvalidWidth .GetMessage(args[i + 1]) ); #if DEBUG Console.ReadLine(); #endif return(ErrorCode.CLI_InvalidWidth.ToInt()); } MainApp.BytesPerRow = b; } break; case "-dump": case "/dump": dump = true; break; case "/?": case "-h": case "-help": case "--help": ShowHelp(); return(0); case "-v": case "/ver": case "--version": ShowVersion(); return(0); } } if (dump) { Console.Write("Dumping file... "); ErrorCode err = Dumper.Dump(entry, MainApp.BytesPerRow, MainApp.OffsetView); Console.WriteLine(err.GetMessage()); return(err.ToInt()); } else { #if DEBUG // I want Visual Studio to catch the exceptions! MainApp.Open(entry); ErrorCode e = MainApp.LastError; Console.Clear(); Console.WriteLine( $"ERROR: {e} - {e.GetMessage()} (0x{e.ToInt():X8})" ); Console.ReadKey(); return(e.ToInt()); #else try { MainApp.Open(entry); if (MainApp.LastError != ErrorCode.Success) { Console.WriteLine(MainApp.LastError.GetMessage()); } return(MainApp.LastError.ToInt()); } catch (Exception e) { Abort(e); } return(0); #endif } }
static void ConsoleShowError(ErrorCode errorCode, string parameter = "") { Console.WriteLine(errorCode.GetMessage(parameter)); Console.WriteLine(HelpString); }
public AssemblyToolKernelException(ErrorCode errorCode, AssemblyToolKernelException innerexception) : base(errorCode.GetMessage(), innerexception) { Code = new[] { errorCode }; }
public AssemblyToolKernelException(ErrorCode errorCode) : base(errorCode.GetMessage()) { Code = new[] { errorCode }; }