/// <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); } }
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"]); }
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); }
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 })); }
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()); }
public void Error(Exception e, object data) { e.AddData(data); LogMessage(LogLevel.Error, e); }
public void Warn(Exception e, object data) { e.AddData(data); LogMessage(LogLevel.Warn, e, null, null); }
public static Exception AddData(this Exception exception, string name, string value) { return(exception.AddData <Exception>(name, value)); }