Skip to content

Commit

Permalink
Catch exceptions when making calls to ISAR
Browse files Browse the repository at this point in the history
  • Loading branch information
andchiind committed Oct 21, 2024
1 parent 1d0fd2c commit e1626bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 15 additions & 6 deletions backend/api/Services/IsarService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ public async Task<IsarMission> StartMission(Robot robot, MissionRun missionRun)
mission_definition = new IsarMissionDefinition(missionRun, includeStartPose: missionRun.MissionRunType == MissionRunType.Localization)
};

var response = await CallApi(
HttpMethod.Post,
robot.IsarUri,
"schedule/start-mission",
missionDefinition
);
HttpResponseMessage? response;
try
{
response = await CallApi(
HttpMethod.Post,
robot.IsarUri,
"schedule/start-mission",
missionDefinition
);
}
catch (Exception e)
{
logger.LogError("Encountered an exception when making an API call to ISAR: {Message}", e.Message);
throw new IsarCommunicationException(e.Message);
}

if (!response.IsSuccessStatusCode)
{
Expand Down
4 changes: 2 additions & 2 deletions backend/api/Services/MissionSchedulingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ or MissionRunNotFoundException
{
logger.LogError(
ex,
"Mission run {MissionRunId} was not started successfully due to {ErrorMessage}",
"Mission run {MissionRunId} was not started successfully. {ErrorMessage}",
missionRun.Id,
ex.Message
);
await missionRunService.SetMissionRunToFailed(missionRun.Id, $"Mission run '{missionRun.Id}' was not started successfully due to '{ex.Message}'");
await missionRunService.SetMissionRunToFailed(missionRun.Id, $"Mission run '{missionRun.Id}' was not started successfully. '{ex.Message}'");
}
}

Expand Down

0 comments on commit e1626bd

Please sign in to comment.