Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent backend from crashing if no inspectionArea #2046

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/api/EventHandlers/MissionEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private async void OnSendRobotToDockTriggered(object? sender, RobotEmergencyEven
{
await MissionScheduling.ScheduleMissionToDriveToDockPosition(robot.Id);
}
catch (DockException ex)
catch (Exception ex) when (ex is DockException || ex is InspectionAreaNotFoundException)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually split the expceptions, like this, for consistency:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can do it, but the logging and behavior is the same so it would mean duplicated line 161-172. Do you prefer splitting it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, we do this in the mapService as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The looging messages are different tho, one is regarding docking and the other inspection area so i think it is worth it to duplicate it, it is also consistent with most of the code we have. You don't have to because its a preference but for consistency i think it would be good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer this. Less chance of getting bugs where only one of the exceptions have forgotten a return or a signalR message

{
_logger.LogError(
ex,
Expand Down
2 changes: 1 addition & 1 deletion backend/api/Services/MissionSchedulingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public async Task ScheduleMissionToDriveToDockPosition(string robotId)
else
{
string errorMessage =
$"Robot with ID {robotId} could return home as it did not have an inspection area";
$"Robot with ID {robotId} could not return home as it did not have an inspection area";
logger.LogError("{Message}", errorMessage);
throw new InspectionAreaNotFoundException(errorMessage);
}
Expand Down