diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2026-03-09 00:00:39 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2026-03-09 00:00:50 +0100 |
| commit | d71f0ed16d175285f2e8cbde6091994c2aa1d962 (patch) | |
| tree | e8b0bcc3f432fa9d5243dd4595af256511643151 /src/Enmarcha.Backend/Controllers | |
| parent | 5288cfbed34f94c4321b8d9dc497cfd0da3ffd26 (diff) | |
Enhance route details handling and add favorites functionality; improve error logging and response structure
Diffstat (limited to 'src/Enmarcha.Backend/Controllers')
| -rw-r--r-- | src/Enmarcha.Backend/Controllers/TransitController.cs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/Enmarcha.Backend/Controllers/TransitController.cs b/src/Enmarcha.Backend/Controllers/TransitController.cs index 7876dbe..9b13972 100644 --- a/src/Enmarcha.Backend/Controllers/TransitController.cs +++ b/src/Enmarcha.Backend/Controllers/TransitController.cs @@ -124,8 +124,21 @@ public class TransitController : ControllerBase var query = RouteDetailsContent.Query(new RouteDetailsContent.Args(id, serviceDate)); var response = await SendOtpQueryAsync<RouteDetailsResponse>(query); - if (response?.Data?.Route == null) + if (response == null) { + return StatusCode(500, "Failed to connect to OTP."); + } + + if (!response.IsSuccess) + { + var messages = string.Join("; ", response.Errors?.Select(e => e.Message) ?? []); + _logger.LogError("OTP returned errors: {Errors}", messages); + return StatusCode(500, $"OTP Error: {messages}"); + } + + if (response.Data?.Route == null) + { + _logger.LogWarning("Route details not found for {Id} on {ServiceDate}", id, serviceDate); return NotFound(); } |
