/// <summary> /// Uses recursion to save exceptions and inner exceptions /// </summary> /// <param name="exception"></param> /// <param name="uuid"></param> /// <returns></returns> public async Task LogExeptionAsync(Exception exception, Guid uuid) { if (exception == null || _counter >= 3) { return; } var ex = new UnprocessedException(nameof(exception), $"{exception.Message} - {exception.StackTrace}", uuid, _counter); await SaveExceptionModelAsync(ex); await LogExeptionAsync(exception.InnerException, uuid); }
protected async Task SaveExceptionModelAsync(UnprocessedException exception) { _context.Set <UnprocessedException>().Add(exception); await _context.SaveChangesAsync(); }