public override async Task Invoke(IOwinContext context) { try { await Next.Invoke(context); var exception = context.Get <Exception>(ElmoConstants.ExceptionKey); if (exception != null) { throw exception; } } catch (Exception exception) { try { await errorLog.LogAsync(new Error(exception, context)); } catch (Exception e) { logger.WriteError("An error occured while logging the error in Elmo.", e); } } }