From a73929949e3033eed384b2a15e2aa2cfcd347114 Mon Sep 17 00:00:00 2001 From: Dan Schultzer <1254724+danschultzer@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:45:34 -0800 Subject: [PATCH] Surface retriever startup error --- lib/money/exchange_rates/exchange_rates_supervisor.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/money/exchange_rates/exchange_rates_supervisor.ex b/lib/money/exchange_rates/exchange_rates_supervisor.ex index 51fc399..7944881 100644 --- a/lib/money/exchange_rates/exchange_rates_supervisor.ex +++ b/lib/money/exchange_rates/exchange_rates_supervisor.ex @@ -38,7 +38,7 @@ defmodule Money.ExchangeRates.Supervisor do options = Keyword.merge(default_options(), options) if options[:restart], do: stop() supervisor = start_link() - if options[:start_retriever], do: ExchangeRates.Retriever.start() + if options[:start_retriever], do: start_retriever!() supervisor end @@ -189,4 +189,11 @@ defmodule Money.ExchangeRates.Supervisor do defp retriever_spec(config) do %{id: @child_name, start: {@child_name, :start_link, [@child_name, config]}} end + + defp start_retriever! do + case ExchangeRates.Retriever.start() do + {:ok, _pid} -> :ok + {:error, reason} -> raise "Unhandled error starting retriever; #{inspect reason}" + end + end end