From 13166a62eb8635d0aaf91de96e666ce9eab2cfa9 Mon Sep 17 00:00:00 2001 From: Eddasol Date: Mon, 24 Feb 2025 14:09:25 +0100 Subject: [PATCH] Prevent backend from crashing if no inspectionArea --- backend/api/EventHandlers/MissionEventHandler.cs | 2 +- backend/api/Services/MissionSchedulingService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/api/EventHandlers/MissionEventHandler.cs b/backend/api/EventHandlers/MissionEventHandler.cs index 26b00259..ecedeabb 100644 --- a/backend/api/EventHandlers/MissionEventHandler.cs +++ b/backend/api/EventHandlers/MissionEventHandler.cs @@ -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) { _logger.LogError( ex, diff --git a/backend/api/Services/MissionSchedulingService.cs b/backend/api/Services/MissionSchedulingService.cs index 10384783..217548b8 100644 --- a/backend/api/Services/MissionSchedulingService.cs +++ b/backend/api/Services/MissionSchedulingService.cs @@ -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); }