コード例 #1
0
 /// <summary>
 ///     Add's a command's parameters to an exceptions data dictionary
 /// </summary>
 /// <param name="e"></param>
 /// <param name="cmd"></param>
 public static void AddCommandParameters(this Exception e, DbCommand cmd)
 {
     e.AddData("sql", cmd.CommandText);
     e.AddData("connection", cmd.Connection.ConnectionString);
     foreach (IDbDataParameter p in cmd.Parameters)
     {
         e.AddData(p.ParameterName, p.Value);
     }
 }
コード例 #2
0
        public void When_adding_the_same_data_twice()
        {
            //Arrange
            var e = new Exception();

            e.AddData("A", "A1");

            //Act
            e.AddData("A", "A2");

            //Assert
            Assert.AreEqual("A2", e.Data["A"]);
        }
コード例 #3
0
        public static Exception AddData(this Exception ex, [CanBeNull] Error[] errors)
        {
            if (errors == null)
            {
                return(ex);
            }
            foreach (var error in errors)
            {
                ex.AddData(error.Code, error.Description);
            }

            return(ex);
        }
コード例 #4
0
        public async Task <IActionResult> Error()
        {
            IExceptionHandlerFeature feature = HttpContext.Features.Get <IExceptionHandlerFeature>();
            Exception ex = feature?.Error;

            if (ex != null)
            {
                User user = await GetUserAsync();

                if (user != null)
                {
                    ex.AddData("User", user.Email);
                    ex.AddData("User id", user.Id);
                }
            }

            logger.LogError(ex, "Error");

            return(ErrorMessage(new ErrorModel()
            {
                Title = "Oops! an error has occured", Text = ex?.Message
            }));
        }
コード例 #5
0
ファイル: BuildSession.cs プロジェクト: Temp1ar/Armature
        private void AddDebugData(Exception exception)
        {
            if (exception.Data.Contains(ExceptionData.BuildSequence))
            {
                return;
            }

            var sb = new StringBuilder();

            foreach (var unitInfo in _buildSequence)
            {
                sb.AppendLine(unitInfo.ToString());
            }

            exception.AddData(ExceptionData.BuildSequence, sb.ToString());
        }
コード例 #6
0
 public void Error(Exception e, object data)
 {
     e.AddData(data);
     LogMessage(LogLevel.Error, e);
 }
コード例 #7
0
 public void Warn(Exception e, object data)
 {
     e.AddData(data);
     LogMessage(LogLevel.Warn, e, null, null);
 }
コード例 #8
0
 public static Exception AddData(this Exception exception, string name, string value)
 {
     return(exception.AddData <Exception>(name, value));
 }