Beispiel #1
0
        public string RecuperarDetalleError(Exception exception)
        {
            var format = new MessageFormat();
            DetalleError(exception, format);

            return format.Message;
        }
Beispiel #2
0
        private void DetalleError(Exception exception, MessageFormat format)
        {
            Type tipo = exception.GetType();
            var handler = _map.ContainsKey(tipo) ? _map[tipo] : _map[typeof (Exception)];

            handler.AddExceptionInformation(format, exception);
        }
        public virtual void AddExceptionInformation(MessageFormat messageFormat, Exception excepcion)
        {
            var sqlexcepcion = excepcion as SqlException;

            int contEx = 1;

            messageFormat.AddExtraInformation("SqlException.Server", sqlexcepcion.Server);
            messageFormat.AddExtraInformation("SqlException.Procedure", sqlexcepcion.Procedure);
            messageFormat.AddExtraInformation("SqlException.LineNumber", sqlexcepcion.LineNumber.ToString());
            messageFormat.AddExtraInformation("SqlException.Message", sqlexcepcion.Message);
            messageFormat.AddExtraInformation("SqlException.Number", sqlexcepcion.Number.ToString());
            messageFormat.AddExtraInformation("SqlException.Class", sqlexcepcion.Class.ToString());
            messageFormat.AddExtraInformation("SqlException.State", sqlexcepcion.State.ToString());
            messageFormat.AddExtraInformation("SqlException.ErrorCode", sqlexcepcion.ErrorCode.ToString());

            foreach (SqlError errorSql in sqlexcepcion.Errors)
            {
                string tituloSqlError = string.Format("SqlException.SqlError{0}", contEx);
                messageFormat.AddExtraInformation(tituloSqlError + ".Server", errorSql.Server);
                messageFormat.AddExtraInformation(tituloSqlError + ".Procedure", errorSql.Procedure);
                messageFormat.AddExtraInformation(tituloSqlError + ".LineNumber", errorSql.LineNumber.ToString());
                messageFormat.AddExtraInformation(tituloSqlError + ".Message", errorSql.Message);
                messageFormat.AddExtraInformation(tituloSqlError + ".Number", errorSql.Number.ToString());
                messageFormat.AddExtraInformation(tituloSqlError + ".Class", errorSql.Class.ToString());
                messageFormat.AddExtraInformation(tituloSqlError + ".State", errorSql.State.ToString());
                contEx++;
            }
        }
        public virtual void AddExceptionInformation(MessageFormat messageFormat, Exception excepcion)
        {
            int contExcepcionInterna = 0;

            messageFormat.AddExtraInformation("Exception.Type", excepcion.GetType().Name);
            messageFormat.AddExtraInformation("Exception.Message", excepcion.Message);

            Exception excepcionInterna = excepcion.InnerException;
            while (excepcionInterna != null)
            {
                contExcepcionInterna++;

                string tituloExcepcionInterna = string.Format("Exception.InnerException{0}", contExcepcionInterna);

                messageFormat.AddExtraInformation(tituloExcepcionInterna + ".Type", excepcion.InnerException.GetType().Name);
                messageFormat.AddExtraInformation(tituloExcepcionInterna + ".Message", excepcion.InnerException.Message);

                excepcionInterna = excepcionInterna.InnerException;
            }

            if (excepcion.StackTrace != null)
            {
                messageFormat.AddExtraInformation("Exception.StackTrace", excepcion.StackTrace);
            }
        }
Beispiel #5
0
        public void AddExceptionInformation(MessageFormat messageFormat, 
            Exception excepcion)
        {
            var error = (ExcepcionReglaNegocio) excepcion;

            messageFormat.AddExtraInformation("Tipo","Error de prueba");
            messageFormat.AddExtraInformation("Cantidad de errores", "8");
            messageFormat.AddExtraInformation("Duracion", "48");
            messageFormat.AddExtraInformation("Codigo", error.Codigo);
            messageFormat.AddExtraInformation("Mensajes", error.Message);
        }