I have this code
var vehicle = await _vehicleService.GetVehicle(registrationNumber);
if (vehicle == null)
return false;
We use Sentry error logging and for some reason, we get a steady flow of errors reported at the line and char of the return false text (line 28 char 34 in our case).
How is that even possible? This whole line is to handle the case where we don't get any vehicle back from the service and therefor returns false to the calling method.
Method that causes the error:
public async Task<bool> CreateCallback(string registrationNumber, int departmentNr, string departmentName, string customerName, string customerPhone, int multiBrandErrand, int bmwBrandErrand)
{
var vehicle = await _vehicleService.GetVehicle(registrationNumber);
if (vehicle == null) return false;
int errand;
string entrance;
if (vehicle.Brand.ToLower() == "bmw" || vehicle.Brand.ToLower() == "mini")
The called method, using flurl:
public async Task<AutonetVehicleResult> GetVehicle(string registrationNumber)
{
try
{
var vehicle = await $"https://fakeapiurl/api/vehicle/{registrationNumber}"
.GetJsonAsync<AutonetVehicleResult>();
return vehicle;
}
catch (Exception)
{
return null;
}
}