From 219bf5893c3ec5bab96212664423e400fd9b2373 Mon Sep 17 00:00:00 2001 From: Nick Stein Date: Tue, 16 Apr 2024 11:54:32 -0400 Subject: [PATCH] chore: add descriptive error message upon attempting to access non-existent stop_id (#789) * fix: allow nil stops through * chore: change to descriptive exception --- apps/state/lib/state/shape.ex | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/state/lib/state/shape.ex b/apps/state/lib/state/shape.ex index ade37835..0d46264e 100644 --- a/apps/state/lib/state/shape.ex +++ b/apps/state/lib/state/shape.ex @@ -268,8 +268,14 @@ defmodule State.Shape do into: MapSet.new() do # use the parent station ID case State.Stop.by_id(schedule.stop_id) do - %{id: id, parent_station: nil} -> id - %{parent_station: id} -> id + %{id: id, parent_station: nil} -> + id + + %{parent_station: id} -> + id + + nil -> + raise "schedule_stop_id=#{schedule.stop_id} Schedule stop_id is not present in Stop state." end end end