public async Task CreateExceptionAsync(ExceptionTableModel exception) { try { var p = new DynamicParameters(); p.Add("value", exception.Value); p.Add("stackTrace", exception.StackTrace); p.Add("userId", exception.UserId); await _db.QueryAsync <int>("CreateException", p, commandType : CommandType.StoredProcedure); } catch (Exception ex) { return; } }
public async Task Invoke(HttpContext context) { try { await _next.Invoke(context); } catch (Exception ex) { var userId = context.User.FindFirstValue(ClaimTypes.NameIdentifier); var exeption = new ExceptionTableModel() { UserId = userId, Value = ex.Message, StackTrace = ex.StackTrace, }; await _exceptionsRepository.CreateExceptionAsync(exeption); await _next.Invoke(context); } }