public async Task Consume(ConsumeContext <TCommand> context) { try { IAggregateRoot aggregateRoot = await _handler.ExecuteAsync(context.Message); _eventFactory.Make(aggregateRoot.Events); await aggregateRoot.CommitAsync(_aggregateStore); foreach (var composite in aggregateRoot.Events) { await context.Publish(composite.Event, composite.Event.GetType()); } await context.RespondAsync(new Common.Cqrs.Responses.Response(aggregateRoot.Id)); } catch (ValidationException ex) { await context.RespondAsync(new BadRequestResponse(ex)); } catch (TelegramClientException ex) { await context.RespondAsync(new BadRequestResponse(ex)); } catch (Exception ex) { var exceptionId = _exceptionHandler.Handle(ex, context.Message); await context.RespondAsync(message : new ErrorResponse(exceptionId)); } }