diff --git a/SatWatcher/Data/TLEApi.cs b/SatWatcher/Data/TLEApi.cs index 00ea356..2840bdb 100644 --- a/SatWatcher/Data/TLEApi.cs +++ b/SatWatcher/Data/TLEApi.cs @@ -35,12 +35,19 @@ public static Result GetSatellite(long id) } var tleResponse = JObject.Parse(response); - var results = tleResponse["member"]?.Children().ToList().First(); + var results = tleResponse["member"]?.Children().ToList(); + + if (results?.Count != 1) + { + return Result.Failure($"{results.Count} satellites with this number were found"); + } + + var result = results.First(); return new Satellite( - GetValue(results, "satelliteId"), - GetValue(results, "name"), - GetValue(results, "line1"), - GetValue(results, "line2") + GetValue(result, "satelliteId"), + GetValue(result, "name"), + GetValue(result, "line1"), + GetValue(result, "line2") ); }