From 33c60e5753bcf4aa1989f66d5beb6c29c14a5c24 Mon Sep 17 00:00:00 2001 From: William Sawyer Date: Mon, 14 Oct 2024 15:33:59 +0000 Subject: [PATCH] Return 500 on failed MQTT message --- Mortein/Controllers/CommandController.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Mortein/Controllers/CommandController.cs b/Mortein/Controllers/CommandController.cs index a0a48bb..fb9aee5 100644 --- a/Mortein/Controllers/CommandController.cs +++ b/Mortein/Controllers/CommandController.cs @@ -68,11 +68,18 @@ private static string ConstructTopicName(Guid deviceId) [ProducesResponseType(StatusCodes.Status204NoContent)] public IActionResult ToggleDeviceVibration(Guid deviceId) { - PublishCommand(deviceId, new ToggleVibrationCommand() + try { - DeviceId = deviceId, - }); - return NoContent(); + PublishCommand(deviceId, new ToggleVibrationCommand() + { + DeviceId = deviceId, + }); + return NoContent(); + } + catch + { + return Problem(); + } } ///