From 5d407bb5f07cf1409154678e8ddcd27d3222fdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saint-Sevin?= Date: Fri, 17 Nov 2023 20:05:58 +0100 Subject: [PATCH] allow a start error to properly propagate for the caller to take the appropriate action --- lib/scenic.ex | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/scenic.ex b/lib/scenic.ex index 1e030e58..ca2fbe1d 100644 --- a/lib/scenic.ex +++ b/lib/scenic.ex @@ -64,13 +64,17 @@ defmodule Scenic do def start_link(vps \\ []) def start_link(vps) when is_list(vps) do - {:ok, pid} = Supervisor.start_link(__MODULE__, nil, name: :scenic) + case Supervisor.start_link(__MODULE__, nil, name: :scenic) do + {:ok, pid} -> + # start the default ViewPort + Enum.each(vps, &Scenic.ViewPort.start(&1)) - # start the default ViewPort - Enum.each(vps, &Scenic.ViewPort.start(&1)) + # return the original start_link value + {:ok, pid} - # return the original start_link value - {:ok, pid} + error -> + error + end end # --------------------------------------------------------