I have the following method:
public Task<Envelope<Response>> Handle(Request request, CancellationToken cancellationToken) {
List<Error> errors = _validator.Validate(request));
if (errors.Any())
return new Envelope<Response>(errors);
return _handler.Handle(request, cancellationToken);
}
If there are any errors I need to to return Envelope<Response>(errors)
.
The problem is the method returns Task<Envelope<Response>>
.
How to create and return the Task?