GetDatesRange Fix handle exception "Well id: {idWell} does not contain telemetry."

This commit is contained in:
ngfrolov 2022-11-21 16:58:37 +05:00
parent 41816719b9
commit 9b06438935
2 changed files with 10 additions and 6 deletions

View File

@ -332,7 +332,7 @@ namespace AsbCloudInfrastructure.Services
throw new Exception($"Well id: {idWell} does not exist.");
if (well.IdTelemetry is null)
throw new Exception($"Well id: {idWell} does not contain telemetry.");
throw new KeyNotFoundException($"Well id: {idWell} does not contain telemetry.");
return telemetryService.GetDatesRange((int)well.IdTelemetry);
}

View File

@ -115,11 +115,15 @@ namespace AsbCloudWebApi.Controllers.SAUB
if (!isCompanyOwnsWell)
return Forbid();
var dataDatesRange = wellService.GetDatesRange(idWell);
return Ok(dataDatesRange);
try
{
var dataDatesRange = wellService.GetDatesRange(idWell);
return Ok(dataDatesRange);
}
catch(KeyNotFoundException)
{
return NoContent();
}
}
}
}