Esempio n. 1
0
    static void Main()
    {
        MyError err = new MyError("aaa");

        Console.WriteLine(err.msg);
        Console.WriteLine("<%END%>");
    }
Esempio n. 2
0
        public void OnException(ExceptionContext context)
        {
            var appException = context.Exception as MyAppException;
            var errorCode    = appException?.ErrorCode ?? 0;

            // create my error for custom solution
            var cutomError = new MyError
            {
                MyCustomErrorCode = errorCode,
                FieldName         = string.IsNullOrEmpty(appException.Field) ? null : appException.Field
            };

            // custom error management
            if (errorCode >= 400 && errorCode <= 499)
            {
                // all this codes return a 400 as HTTP response

                context.Result = new ObjectResult(cutomError)
                {
                    StatusCode   = 400,
                    DeclaredType = typeof(MyError)
                };
            }
            else
            {
                // all the other codes return a 500 as HTTP response
                context.Result = new ObjectResult(cutomError)
                {
                    StatusCode   = 500,
                    DeclaredType = typeof(MyError)
                };
            }
        }
Esempio n. 3
0
    IEnumerator WaitForRequest(WWW www)
    {
        yield return(www);

        // check for errors
        if (www.error == null)
        {
            string work = www.text;

            Debug.Log("hello");
            MyError obj = JsonConvert.DeserializeObject <MyError>(work);
            Debug.Log(obj.feeds);
            foreach (var employee in obj.feeds)
            {
                JSON_Time        = employee.created_at;
                JSON_Temperature = employee.field1;
                Debug.Log(employee.created_at);
                Debug.Log(employee.field1);
            }
            _Particle soil = JsonUtility.FromJson <_Particle>(work);
            JSON_Name = soil.channel.name;
            //JSON_Country = fields.location.country;
            //JSON_Weather = fields.current.condition.text;
            //JSON_Temperature = fields.current.temp_c;
            //temperature = float.Parse (JSON_Temperature);
            //Debug.Log (JSON_Name);
            //Debug.Log (JSON_Country);
            //Debug.Log (JSON_Weather);
            //Debug.Log (JSON_Temperature);
        }
        else
        {
        }
    }
Esempio n. 4
0
 public VMerror(MyError root, VMfunction parent) : base(root, parent)
 {
     this.CommandOpen = new DelegateCommand(() => new ErrorWindow()
     {
         DataContext = this
     }.ShowDialog());
 }
Esempio n. 5
0
        private bool Validar()
        {
            bool paso = true;

            MyError.Clear();

            if (string.IsNullOrWhiteSpace(ComentariotextBox.Text))
            {
                MyError.SetError(ComentariotextBox, "El campo comentario no puede estar vacio");
                ComentariotextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(DepositotextBox.Text))
            {
                MyError.SetError(DepositotextBox, "El campo deposito no puede estar vacio");
                DepositotextBox.Focus();
                paso = false;
            }
            if (string.IsNullOrWhiteSpace(MontotextBox.Text))
            {
                MyError.SetError(MontotextBox, "El campo monto no puede estar vacio");
                MontotextBox.Focus();
                paso = false;
            }
            return(paso);
        }
            public static MyError CreateParsingError(LogMessage syntaxError, string path)
            {
                MyError.ErrorType errorType;
                //CHAPUZ MAXIMO PARA VER SI ES ERROR LEXICO
                var lexicErrorSubString = "Invalid character";

                if (syntaxError.Message.Substring(0, lexicErrorSubString.Length).Equals(lexicErrorSubString))
                {
                    errorType = MyError.ErrorType.Lexic;
                }
                else
                {
                    errorType = MyError.ErrorType.Syntactic;
                }

                var error = new MyError(syntaxError.Message);

                error.Set(syntaxError.Location.Line,
                          syntaxError.Location.Column,
                          path,
                          errorType,
                          MyError.ErrorLevel.Fatal);
                AddError(error);
                return(error);
            }
            public static MyError ArrayDimensionError(AstNode node, Word indexWord)
            {
                string type;
                string value;

                if (indexWord.IsError())
                {
                    type  = indexWord.GetType().Name;
                    value = "";
                }
                else
                {
                    type  = TypeConstants.GetMyTypeName(((PyObj)indexWord).GetMyType());
                    value = ((PyObj)indexWord).MyToString();
                }
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "Indice no valido en declaracion de Array: " + type + " valor: " + value,
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
Esempio n. 8
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            MyError.Clear();
            int id;

            id = Convert.ToInt32(IDnumericUpDown.Value);

            LimpiarCampos();

            if (IdentificarInscripcion(id) == true)
            {
                MessageBox.Show("No se puede eliminar este Estudiante porque tiene una inscripción creada.", "Información",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (EstudianteBLL.Eliminar(id))
                {
                    MessageBox.Show("Estudiante Eliminado", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("No se puede eliminar, porque no existe.");
                }
            }
        }
Esempio n. 9
0
        private bool ValidoAgregar()
        {
            bool paso = true;

            MyError.Clear();

            if (EstudiantecomboBox.SelectedIndex == -1)
            {
                MyError.SetError(EstudiantecomboBox, "Debe elegir al menos un estudiante");
                EstudiantecomboBox.Focus();
                paso = false;
            }
            if (EstudiantecomboBox.Text == string.Empty)
            {
                MyError.SetError(EstudiantecomboBox, "Debe elegir al menos un estudiante");
                EstudiantecomboBox.Focus();
                paso = false;
            }

            if (paso)
            {
                foreach (var objeto in this.Detalles)
                {
                    if (objeto.EstudianteID == (int)(EstudiantecomboBox.SelectedValue))
                    {
                        MyError.SetError(EstudiantecomboBox, "Ya existe un estudiante");
                        EstudiantecomboBox.Focus();
                        return(paso = false);
                    }
                }
            }

            return(paso);
        }
Esempio n. 10
0
 public MyCustomError(@string Message, Abser Abser, MyError MyError, error error)
 {
     this.Message      = Message;
     this.Abser        = Abser;
     this.m_MyErrorRef = new Ref <MyError>(MyError);
     this.error        = error;
 }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            MyError.NewRecord();

            if (textBox1.Text == "")
            {
                MyError.Set(textBox1, "!!!");
            }
            else
            {
                MyError.Clear(textBox1);
            }

            if (textBox2.Text == "")
            {
                MyError.Set(textBox2, "!!!");
            }
            else
            {
                MyError.Clear(textBox2);
            }

            if (MyError.CheckAll())
            {
                MyDialog.Msg("");
            }
        }
Esempio n. 12
0
        public static Exception ErrorServicios(Exception ex)
        {
            var errlog         = new MyError(ex.Message, "Critico");
            var faultException = new FaultException <MyError>(errlog, new FaultReason(ex.ToString()));

            throw faultException;
        }
Esempio n. 13
0
        bool Check()
        {
            MyError.NewRecord();
            if (textBox1.Text.Trim() == "")
            {
                MyError.Set(textBox1, "名称不可为空。");
            }
            else if (textBox1.Text.Trim().Length > 30)
            {
                MyError.Set(textBox1, "名称字数太长。");
            }
            else if (Operation && M.DuplicateLabelGroupName(textBox1.Text.Trim(), LocationID))//新增时,检查是否重名
            {
                MyError.Set(textBox1, "名称重复。");
            }
            else if (!Operation &&
                     row["GroupName"].ToString() != textBox1.Text.Trim() &&
                     M.DuplicateLabelGroupName(textBox1.Text.Trim(), LocationID))//修改时,名称有变,检查是否重名
            {
                MyError.Set(textBox1, "名称重复。");
            }
            else
            {
                MyError.Clear(textBox1);
            }

            return(MyError.CheckAll());
        }
            public static MyError ArrayTypeError(AstNode node, int[] intIndices, Word word)
            {
                string type;
                string value;

                if (word.IsError())
                {
                    type  = word.GetType().Name;
                    value = "";
                }
                else
                {
                    type  = TypeConstants.GetMyTypeName(((PyObj)word).GetMyType());
                    value = ((PyObj)word).MyToString();
                }
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "No se le puede asignar a un array con las dimensiones: [ " + String.Join(", ", intIndices) + " ]. Un objeto tipo: " + type + " valor: " + value,
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
        public void Result_TE_can_be_cast_to_UnitResult()
        {
            var error = new MyError();
            Result <MyClass, MyError> result = Result.Failure <MyClass, MyError>(error);

            UnitResult <MyError> unitResult = result;

            unitResult.IsFailure.Should().BeTrue();
            unitResult.Error.Should().Be(error);
        }
 /// <summary>
 /// Setea los valores de locacion al error y lo agrega a la lista de errores
 /// </summary>
 /// <returns>El error despues de ser editado</returns>
 public static MyError Create(AstNode node, MyError error)
 {
     error.Set(node.Span.Location.Line,
               node.Span.Location.Column,
               node.NodePath.StringValue,
               MyError.ErrorType.Semantic,
               MyError.ErrorLevel.Fatal);
     AddError(error);
     return(error);
 }
Esempio n. 17
0
 private void Limpiar()
 {
     IncripcionIDnumericUpDown.Value = 0;
     EstudianteIDnumericUpDown.Value = 0;
     FechadateTimePicker.Value       = DateTime.Now;
     MontotextBox.Text      = string.Empty;
     DepositotextBox.Text   = string.Empty;
     BalancetextBox.Text    = string.Empty;
     ComentariotextBox.Text = string.Empty;
     MyError.Clear();
 }
 public static MyError MainNotFound(PyPath nodePath, MyError error)
 {
     error.Message = "Main no definido";
     error.Set(-1,
               -1,
               nodePath.StringValue,
               MyError.ErrorType.Semantic,
               MyError.ErrorLevel.Warning);
     AddError(error);
     return(error);
 }
Esempio n. 19
0
 /// <summary>
 /// 「readme.txtを見る」ボタンをクリックしたとき呼ばれるイベントハンドラ
 /// </summary>
 /// <param name="sender">The parameter is not used.</param>
 /// <param name="e">The parameter is not used.</param>
 private void OpenTextFileButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Process.Start("readme.txt");
     }
     catch (Win32Exception)
     {
         MyError.CallErrorMessageBox($"カレントフォルダにreadme.txtが見つかりません。{Environment.NewLine}readme.txtを削除しないで下さい。");
     }
 }
        public void Error_in_Result_TE_of_can_be_cast_dynamicly()
        {
            dynamic error  = new MyError();
            dynamic result = Result.Failure <string, MyError>(error);

            var cast = (Result <string, dynamic>)result;

            MyError castError = cast.Error;

            castError.Should().Be(error);
        }
Esempio n. 21
0
        /// <summary>
        /// 例外を受け取り、例外の内容からエラー文字列を生成
        /// そのエラー文字列をメッセージボックスで表示する
        /// さらに、その例外の内容をログに書き込む
        /// アプリケーションを強制終了する
        /// </summary>
        /// <param name="ex">受け取る例外</param>
        private void ReportUnhandledException(Exception ex)
        {
            // 例外の内容からエラー文字列を生成
            // 生成したエラー文字列の内容をメッセージボックスで表示
            MyError.CallErrorMessageBox(this.CreateErrorMessage(ex));

            // 例外の内容をログに書き込む
            MyError.WriteLog(ex);

            this.Shutdown();
        }
            public static Word NoValueReturnedInFunction(AstNode node)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "Funcion no tiene retorno, se a retornado null para continuar la ejecucion ",
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
            public static Word MultipleDefaultInSwitch(AstNode node)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "Solo puede tener una switchlabel: default",
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
Esempio n. 24
0
        private bool ValidaRemover()
        {
            bool paso = true;

            if (DetalledataGridView.SelectedRows == null)
            {
                MyError.SetError(Removerbutton, "Debe seleccionar al menos una fila.");
                paso = false;
            }

            return(paso);
        }
            public static Word NotValidOperationInSwitch(AstNode node)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "La comparacion de uno de los casos del switch retorno un tipo no booleano",
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
            public static MyError MultipleTrueCasesInSwitch(AstNode node)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "Existe mas de un caso que retorna verdadero en el switch",
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
            public static Word VoidGetMember(AstNode node)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "No se puede obtener el miembro de void",
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
            public static Word PathNotValid(AstNode node, string path)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "Direccion de graph o import: " + path + " no es valida",//Chapuz minimo, deberia de decir si es graph o import no los dos
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
            public static Word DotError(AstNode node, string dotErrorMessage)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            dotErrorMessage,//Chapuz minimo, deberia de decir si es graph o import no los dos
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }
            internal static Word AlreadyDefinedProcedure(AstNode node, string procedureName, int procedureParamCount)
            {
                MyError error = new MyError(node.Span.Location.Line,
                                            node.Span.Location.Column,
                                            node.NodePath.StringValue,
                                            "Ya existe un metodo definido en este entorno con el nombre: " + procedureName + " y numero de parametros: " + procedureParamCount.ToString(),
                                            MyError.ErrorType.Semantic,
                                            MyError.ErrorLevel.Fatal);

                AddError(error);
                return(error);
            }