i have a web api that has a response model when it gets results back it assigns the results to the values set as follows:
 public class ResponseHandler
    {
        public string id { get; set; }
        public double balance { get; set; }
        public string currency { get; set; }
        public int errorcode { get; set; }
        public string errorDescription { get; set; }
    }
and this response handler gets called in bellow:
public async Task<ResponseHandler> ExecuteAsync(CheckCommand command)
        {        
                var check = await _client.CheckAsync( command.id);
                _httpContextAccessor.HttpContext.Items["CommandResult"] = check;
                return new ResponseHandler
                {
                    id = check.ID.ToString(),
                    balance = decimal.ToDouble(check.AccountBalance),
                    currency = check.CurrencyCode,
                    errorcode = 0,
                    errorDescription = "null"
                };
        }
so basically if theres no error that comes back then i will assign the errocode to 0. So my question is how do i check if my request is successful then assign the errocode to 0 if its not successful then how do i assign that error to the error description
this is what i tried
        public async Task<ResponseHandler> ExecuteAsync(CheckCommand command)
                {        try{
                        var check = await _client.CheckAsync( command.id); // it fails here and doesnt even hit my catch method when it returns an error
                        _httpContextAccessor.HttpContext.Items["CommandResult"] = check;
                        return new ResponseHandler
                        {
                            id = check.ID.ToString(),
                            balance = decimal.ToDouble(check.AccountBalance),
                            currency = check.CurrencyCode,
                            errorcode = 0,
                            errorDescription = "null"
                        };
    }
    catch(exception ex){
    }
                }
how do i catch the error coming from CheckAsync
 
    