Esempio n. 1
0
        public void Trigger(ErrorType type, Location location, string message)
        {
            string locstring = location == null ? "" : " at " + location.ToString();

            Console.WriteLine(type.ToString() + locstring + ": " + message);

            fatalErrorOccured |= IsFatalError(type);
        }
Esempio n. 2
0
 //     INITIALIZATION
 //_________________________________________________________________________________________
 /// <summary>
 /// Creates a new derived error function.
 /// </summary>
 /// <param name="prototype"> The next object in the prototype chain. </param>
 /// <param name="type"> The type of error, e.g. Error, RangeError, etc. </param>
 internal ErrorConstructor(ObjectInstance prototype, ErrorType type)
     : base(prototype, __STUB__Construct, __STUB__Call)
 {
     // Initialize the constructor properties.
     var properties = new List<PropertyNameAndValue>(3);
     InitializeConstructorProperties(properties, type.ToString(), 1, ErrorInstance.CreatePrototype(Engine, this, type));
     FastSetProperties(properties);
 }
Esempio n. 3
0
 public static void ShowError(ErrorType et)
 {
     MessageBox.Show(Type.GetType("OES.Error.ErrorTable").GetField(et.ToString()).GetValue(null).ToString());
     //switch (et)
     //{
     //    case ErrorType.LoginNoPersonError:
     //        MessageBox.Show(ErrorTable.LoginNoPersonError);
     //        break;
     //    case ErrorType.RARNotExist:
     //        MessageBox.Show(ErrorTable.RARNotExist);
     //        break;
     //}
 }
Esempio n. 4
0
 public override string ToString()
 {
     return("[" + Id + "]" + "[" + Type.ToString() + "]" + "[" + Policy.ToString() + "]" + "[" + Error.ToString() + "]" + " (" + Message + ")");
 }
Esempio n. 5
0
 public static void Raise(ErrorType ErrorType, string Message = null)
 {
     rb_raise(GetConst(Object.Class, ErrorType.ToString()), Message ?? "");
 }
Esempio n. 6
0
        private static string errorTypeToString(ErrorType errorType)
        {
            switch (errorType)
            {
            case ErrorType.AUTH:
                return("auth");

            case ErrorType.WAIT:
                return("wait");

            case ErrorType.MODIFY:
                return("modify");

            case ErrorType.CANCEL:
                return("cancel");

            default:     // Should not happen
                throw new NotImplementedException("No string representation for ErrorType: " + errorType.ToString());
            }
        }
Esempio n. 7
0
 public override string ToString()
 {
     return(Type.ToString() + " Error at Line " + LineNumber.ToString() + ": " + Message);
 }
Esempio n. 8
0
 private void w_OnError(Exception ex, ErrorType errorType, string curUrl)
 {
     MessageBox.Show("采集发送错误,错误类型:" + errorType.ToString() + "详情:\n" + StringFormat.FormatExceptionString(ex), "网络采集器", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Esempio n. 9
0
        public static void Fatal(ErrorType type, Token token)
        {
            string error = token.Line.ToString() + ", " + token.Pos.ToString() + " : " + type.ToString() + " : " + token.Text;

            throw new Exception(error);
        }
Esempio n. 10
0
 private void w_OnError(Exception ex, ErrorType errorType, string curUrl)
 {
     MessageBox.Show("采集发送错误,错误类型:" + errorType.ToString() + "详情:\n" + StringFormat.FormatExceptionString(ex), "网络采集器", MessageBoxButtons.OK, MessageBoxIcon.Error);
 }
Esempio n. 11
0
        /// <summary>
        /// Throws an error with the given <see cref="ErrorType"/> and error message.
        /// </summary>
        public SObject ThrowError(ErrorType errorType, string message)
        {
            string strErrorType = errorType.ToString();

            //TODO: Create error object here and put it as argument in the method call.
            
            return ThrowError(null);
        }
Esempio n. 12
0
        /// <summary>
        /// Throws an error with the given <see cref="ErrorType"/> and error message.
        /// </summary>
        public SObject ThrowError(ErrorType errorType, string message, params object[] messageArgs)
        {
            var formattedMessage = string.Format(message, messageArgs);

            var errorObject = _processor.Context.CreateInstance("Error", new SObject[] { _processor.CreateString(formattedMessage),
                                                                                         _processor.CreateString(errorType.ToString()),
                                                                                         _processor.CreateNumber(_processor.GetLineNumber()) });

            return(ThrowError(errorObject));
        }
Esempio n. 13
0
 /// <summary>
 /// Creates the Error prototype object.
 /// </summary>
 /// <param name="engine"> The script environment. </param>
 /// <param name="constructor"> A reference to the constructor that owns the prototype. </param>
 /// <param name="type"> The type of error, e.g. Error, RangeError, etc. </param>
 internal static ObjectInstance CreatePrototype(ScriptEngine engine, ErrorConstructor constructor, ErrorType type)
 {
     var result = CreateRawObject(GetPrototype(engine, type));
     var properties = GetDeclarativeProperties(engine);
     properties.Add(new PropertyNameAndValue("constructor", constructor, PropertyAttributes.NonEnumerable));
     properties.Add(new PropertyNameAndValue("name", type.ToString(), PropertyAttributes.NonEnumerable));
     properties.Add(new PropertyNameAndValue("message", string.Empty, PropertyAttributes.NonEnumerable));
     result.FastSetProperties(properties);
     return result;
 }
Esempio n. 14
0
    private static string GetErrorType(ErrorType errorType)
    {
        var da = (DescriptionAttribute[])(errorType.GetType().GetField(errorType.ToString())).GetCustomAttributes(typeof(DescriptionAttribute), false);

        return(da.Length > 0 ? da[0].Description : errorType.ToString());
    }
Esempio n. 15
0
        public TestLine ExecuteCorrectTest(string arguments, int timeLimit)
        {
            TestLine testResult = new TestLine {
                testcase = arguments
            };

            if (!FindExePath(_binaryInfo))
            {
                Logger.Error("No Echo.exe file!", _logFile);
                testResult.passed = TestLine.FAIL;
                testResult.res    = ErrorType.NoSudokuExe.ToString();
                return(testResult);
            }

            _binaryInfo.Arguments = arguments;
            try
            {
                Stopwatch timeWatch = new Stopwatch();
                timeWatch.Start();
                // Start the process with the info we specified.
                // Call WaitForExit and then the using statement will close.
                using (Process exeProcess = Process.Start(_binaryInfo))
                {
                    //Start monitor
                    exeProcess.WaitForExit(timeLimit * 1000);
                    timeWatch.Stop();
                    //Release all resources
                    if (!exeProcess.HasExited)
                    {
                        //Give system sometime to release resource
                        exeProcess.Kill();
                        Thread.Sleep(1000);
                    }
                }

                //Check the sudoku file
                string checkFile = Path.Combine(_binaryInfo.WorkingDirectory, "Echo.txt");
                if (!File.Exists(checkFile))
                {
                    Logger.Info("No Echo.txt file!", _logFile);
                    testResult.passed = TestLine.FAIL;
                    testResult.res    = ErrorType.NoGeneratedSudokuTxt.ToString();
                    return(testResult);
                }

                //如果不出现错误的话,则退出
                int tryTimeLimit = 10;
                while (tryTimeLimit > 0)
                {
                    try
                    {
                        File.ReadAllText(checkFile);
                        break;
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(100);
                        tryTimeLimit--;
                    }
                }

                if (tryTimeLimit == 0)
                {
                    Logger.Info("Exe run time out!", _logFile);
                    testResult.passed = TestLine.FAIL;
                    testResult.res    = ErrorType.OutOfTimeCloseExe.ToString();
                    return(testResult);
                }

                //获取错误代码
                ErrorType errorCode = CheckValid(checkFile, arguments);
                if ((int)errorCode > 0)
                {
                    Logger.Info(
                        $"Arguments:{arguments} Normal, spend time {(double)timeWatch.ElapsedMilliseconds / 1000}s",
                        _logFile);
                    testResult.passed = TestLine.SUCCESS;
                    testResult.res    = Convert.ToString((double)timeWatch.ElapsedMilliseconds / 1000);
                    return(testResult);
                }
                testResult.passed = TestLine.FAIL;
                testResult.res    = errorCode.ToString();
                return(testResult);
            }
            catch (Exception e)
            {
                //Log into file to record the runtime error
                Logger.Error($"Arguments:{arguments} RuntimeError:{e.Message}", _logFile);
                testResult.passed = TestLine.FAIL;
                testResult.res    = ErrorType.RuntimeError.ToString();
                return(testResult);
            }
        }
Esempio n. 16
0
        public static IQ ToError(this IQ iq, ErrorType type = ErrorType.cancel, ErrorCondition condition = ErrorCondition.FeatureNotImplemented, string text = "Custom query error.")
        {
            iq.SwitchDirection();
            iq.Type = IqType.error;

            var tag = "";

            switch (condition)
            {
            case ErrorCondition.BadRequest: tag = "bad-request"; break;

            case ErrorCondition.Conflict: tag = "conflict"; break;

            case ErrorCondition.FeatureNotImplemented: tag = "feature-not-implemented"; break;

            case ErrorCondition.Forbidden: tag = "forbidden"; break;

            case ErrorCondition.Gone: tag = "gone"; break;

            case ErrorCondition.InternalServerError: tag = "internal-server-error"; break;

            case ErrorCondition.ItemNotFound: tag = "item-not-found"; break;

            case ErrorCondition.JidMalformed: tag = "jid-malformed"; break;

            case ErrorCondition.NotAcceptable: tag = "not-acceptable"; break;

            case ErrorCondition.NotAllowed: tag = "not-allowed"; break;

            case ErrorCondition.NotAuthorized: tag = "not-authorized"; break;

            case ErrorCondition.NotModified: tag = "not-modified"; break;

            case ErrorCondition.PaymentRequired: tag = "payment-required"; break;

            case ErrorCondition.RecipientUnavailable: tag = "recipient-unavailable"; break;

            case ErrorCondition.Redirect: tag = "redirect"; break;

            case ErrorCondition.RegistrationRequired: tag = "registration-required"; break;

            case ErrorCondition.RemoteServerNotFound: tag = "remote-server-not-found"; break;

            case ErrorCondition.RemoteServerTimeout: tag = "remote-server-timeout"; break;

            case ErrorCondition.ResourceConstraint: tag = "resource-constraint"; break;

            case ErrorCondition.ServiceUnavailable: tag = "service-unavailable"; break;

            case ErrorCondition.SubscriptionRequired: tag = "subscription-required"; break;

            case ErrorCondition.UndefinedCondition: tag = "undefined-condition"; break;

            case ErrorCondition.UnexpectedRequest: tag = "unexpected-request"; break;

            default: tag = "undefined-condition"; break;
            }

            iq.C("error")
            .A("type", type.ToString())
            .C(tag, ns: Namespaces.STANZAS);

            return(iq);
        }
Esempio n. 17
0
        public static string GetEnumDescription(ErrorType value)
        {
            Type type = typeof(ErrorType);

            System.Reflection.FieldInfo [] fis = type.GetFields();
            foreach(System.Reflection.FieldInfo fi in fis) 
            {
                if (fi.Name == value.ToString())
                {
                    XmlEnumAttribute[] attributes = (XmlEnumAttribute[]) fi.GetCustomAttributes(typeof(XmlEnumAttribute), false);
                    foreach (XmlEnumAttribute attr in attributes)
                    {
                        return attr.Name;
                    }
                }
            }
            return null;
        }
Esempio n. 18
0
 public ServerInfoException(ErrorType _type)
     : base("ServerInfo parse error: {0}", _type.ToString())
 {
     Type = _type;
     Log.Exception("ServerInfo parse error: {0}", _type.ToString());
 }
Esempio n. 19
0
 void OnLeaveServer(ErrorType errorType)
 {
     Debug.Log("OnLeaveServer() " + errorType.ToString());
 }
Esempio n. 20
0
 public DomainError(ErrorType errorType, string message, ErrorCode code, IReadOnlyDictionary <string, string>?fields = null) : base(errorType.ToString(), message, (int)code, fields)
 {
 }
Esempio n. 21
0
 public Result(ErrorType err, string description)
 {
     Errno           = (int)err;
     ErrInfo.ErrCode = err.ToString();
     ErrInfo.Value   = description;
 }
Esempio n. 22
0
 public ErrorCodeAttribute(ErrorType type)
 {
     this.Code = type.ToString();
 }
Esempio n. 23
0
 public static void RedirectDialogError(HttpResponse httpresponse, ErrorType errortype)
 {
     RedirectError(httpresponse, "~/home/dialogerror.aspx?type=" + errortype.ToString());
 }
Esempio n. 24
0
        private void sendAuthError(ErrorType errorType, AuthentificationException e)
        {
            Message reply = new Message(new Header("Server", MessageType.ERROR), errorType.ToString() + ";" + e.login);

            sendMessage(reply);
        }
 public DvtelVmsException(ErrorType error) : base(error.ToString())
 {
     Error = error;
 }
Esempio n. 26
0
 private void RaiseErrorAndQuit(ErrorType errorType)
 {
     System.Console.WriteLine("Error on line" + currentLine.ToString() + ": " + errorType.ToString());
     // switch (errorType) {
     //     case ErrorType.VariableDoesntExist:
     //         break;
     //     case ErrorType.InputDoesntExist:
     //         break;
     //     case ErrorType.NotEnoughArguments:
     //         break;
     // }
     Environment.Exit(2);
 }
        internal static string GetErrorText(ErrorType errorType, params object[] errorParameters)
        {
            switch (errorType)
            {
            case ErrorType.Authorisation_AccountLockedOut:
            {
                if (errorParameters.Length > 0)
                {
                    return(string.Format("Your account has been locked out. Please try again in {0} minutes or contact your system administrator.", errorParameters));
                }
                else
                {
                    return("Your account has been locked out. Please try again in a few minutes or contact your system administrator.");
                }
            }

            case ErrorType.Authorisation_Denied:
            {
                if (errorParameters.Length > 0)
                {
                    return(string.Format("Your username and/or password is incorrect. Your account will be locked after {0} attempts.", errorParameters));
                }
                else
                {
                    return("Your username and/or password is incorrect.");
                }
            }

            case ErrorType.SystemError:
            {
                if (errorParameters.Length > 0)
                {
                    return(string.Format("There was a system error ({0}).", errorParameters));
                }
                else
                {
                    return("There was a system error.");
                }
            }

            case ErrorType.AdminOnly:
            {
                if (errorParameters.Length > 0)
                {
                    return(string.Format("Only system administrators can perform this action. ({0}).", errorParameters));
                }
                else
                {
                    return("Only system administrators can perform this action.");
                }
            }


            default:
            {
                if (errorParameters.Length > 0)
                {
                    return(string.Format("{1} ({0})", errorType.ToString(), errorParameters[0]));
                }
                else
                {
                    return(string.Format("An error has occurred ({0}).", errorType.ToString()));
                }
            }
            }
        }
Esempio n. 28
0
 private void sendAuthError(ErrorType errorType, AuthentificationException e)
 {
     Message reply = new Message(new Header("Server", MessageType.ERROR), errorType.ToString() + ";" + e.login);
     sendMessage(reply);
 }
 private static string FormatError(string f, ErrorType t, string s)
 {
     return($"{t.ToString().ToUpper()} {Path.GetFileName(f)} : {s}");
 }
Esempio n. 30
0
 protected void AddModelError(ErrorType type)
 {
     ModelState.AddModelError(type.ToString(), ErrorInfoHelper.Instance[type]);
 }
Esempio n. 31
0
        /// <summary>
        /// 获取默认的消息信息
        /// </summary>
        public static MessageEntity GetMessage(ErrorType errorType, string exceptionMsg = null, string msg = null, string title = null, bool flag = false)
        {
            #region 设置默认的消息信息

            var message = new MessageEntity();
            message.ErrorType     = (int)errorType;
            message.ErrorTypeDesc = errorType.ToString();
            if (msg == null)
            {
                switch (errorType)
                {
                case ErrorType.SqlError:
                    message.Flag  = false;
                    message.Msg   = "系统内部发生错误,请联系管理员!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.SystemError:
                    message.Flag  = false;
                    message.Msg   = "系统发生严重错误,请联系管理员!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.OprationError:
                    message.Flag  = false;
                    message.Msg   = "操作错误,请重试!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.NotUnique:
                    message.Flag  = false;
                    message.Msg   = "不允许有重复数据,请重新输入!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.NoLogin:
                    message.Flag  = false;
                    message.Msg   = "登陆已经过期,请重新登陆!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.NoAuthority:
                    message.Flag  = false;
                    message.Msg   = "您没有权限访问该功能请联系管理员!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.OutOfTime:
                    message.Flag  = false;
                    message.Msg   = "登陆过期!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.NotAvilebalToken:
                    message.Flag  = false;
                    message.Msg   = "Token无效!";
                    message.Title = "提示信息";
                    break;

                case ErrorType.FieldError:
                    message.Flag  = false;
                    message.Msg   = "参数有误!";
                    message.Title = "提示信息";
                    break;
                }
            }
            else
            {
                message.Msg = msg;
            }
            if (exceptionMsg != null)
            {
                message.ExceptionMsg = exceptionMsg;
            }
            if (string.IsNullOrEmpty(message.Msg))
            {
                message.Msg = exceptionMsg;
            }
            if (title != null)
            {
                message.Title = title;
            }
            message.Flag = flag;

            message.Data = new DataInfo()
            {
                Rows = 0, TotalRows = 0, Result = null
            };
            return(message);

            #endregion
        }
Esempio n. 32
0
 public static void Fatal(ErrorType type)
 {
     throw new Exception(type.ToString());
 }
Esempio n. 33
0
        /// <summary>
        /// 获取错误字符串
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        public static ErrorCode GetErrorCode(Exception ex)
        {
            Type      type  = ex.GetType();
            ErrorCode model = new ErrorCode();

            try
            {
                ErrorCodeType errorCodeType = (ErrorCodeType)Enum.Parse(typeof(ErrorCodeType), type.Name);
                ErrorType     errorType     = (ErrorType)Convert.ToInt32(((int)errorCodeType).ToString().Substring(0, 1));
                model.ErrorValue = string.Format("{0}{1}{2}{3}", BuType, (int)errorType, (int)BusinessType.HHTravel, (int)errorCodeType);
                model.ErrorTitle = string.Format("{0},{1},{2}", BusinessType.HHTravel.ToString(), errorType.ToString(), errorCodeType.ToString());
            }
            catch (Exception exp)
            {
                return(null);
            }


            return(model);
        }
Esempio n. 34
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            ErrorType errorType = (ErrorType)value;

            writer.WriteValue(errorType.ToString());
        }
Esempio n. 35
0
 protected void AddModelError(ErrorType type, string msgFormat, params object[] obj)
 {
     string message = string.Format(msgFormat, obj);
     ModelState.AddModelError(type.ToString(), string.Format("{0}, {1}", ErrorInfoHelper.Instance[type], message));
 }
        public override string ToString()
        {
            string res = string.Format("Error type: '{0}', Message: '{1}'", _errorType.ToString(), _message);

            return(res);
        }
Esempio n. 37
0
        /// <summary>
        /// Throws an error with the given <see cref="ErrorType"/> and error message.
        /// </summary>
        public SObject ThrowError(ErrorType errorType, string message, params object[] messageArgs)
        {
            var strErrorType = errorType.ToString();
            var formattedMessage = string.Format(message, messageArgs);

            var errorObject = _processor.Context.CreateInstance("Error", new SObject[] { _processor.CreateString(formattedMessage),
                                                                                         _processor.CreateString(errorType.ToString()),
                                                                                         _processor.CreateNumber(_processor.GetLineNumber()) });

            return ThrowError(errorObject);
        }
Esempio n. 38
0
		protected virtual void OnLog(string Message, ErrorType ErrorType, ErrorOrigin origin)
		{
			var icon = MessageBoxIcon.Error;
			if (ErrorType==ErrorType.Warning)
				icon = MessageBoxIcon.Warning;
			else if (ErrorType==ErrorType.Information || ErrorType==ErrorType.Message)
				icon = MessageBoxIcon.Information;

			MessageBox.Show(Message,origin.ToString() +" "+ ErrorType.ToString(),MessageBoxButtons.OK,icon);

			try
			{
				if (origin == ErrorOrigin.System)
					File.AppendAllText(IDEInterface.ConfigDirectory + "\\sys.log", Message + "\r\n", System.Text.Encoding.Unicode);
			}
			catch { }
		}