From 670f099e5e19c7bbf41a0fdb74a3fd13767fdbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 13 Jul 2023 14:09:13 +0200 Subject: [PATCH] Make NotFoundError reusable --- lib/livebook/secrets.ex | 2 ++ lib/livebook_web/live/hub/edit/personal_component.ex | 9 ++------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/livebook/secrets.ex b/lib/livebook/secrets.ex index d9b09618e..afbba3ba3 100644 --- a/lib/livebook/secrets.ex +++ b/lib/livebook/secrets.ex @@ -1,4 +1,6 @@ defmodule Livebook.Secrets do + # This module is used to store secrets on Livebook.Storage for specific hubs. + # Currently it is only used by personal hub. @moduledoc false alias Livebook.Hubs.Provider diff --git a/lib/livebook_web/live/hub/edit/personal_component.ex b/lib/livebook_web/live/hub/edit/personal_component.ex index 39ba22bfc..c98df503e 100644 --- a/lib/livebook_web/live/hub/edit/personal_component.ex +++ b/lib/livebook_web/live/hub/edit/personal_component.ex @@ -7,12 +7,7 @@ defmodule LivebookWeb.Hub.Edit.PersonalComponent do defmodule NotFoundError do @moduledoc false - - defexception [:secret, plug_status: 404] - - def message(%{secret: secret}) do - "could not find secret matching \"#{secret}\"" - end + defexception [:message, plug_status: 404] end @impl true @@ -25,7 +20,7 @@ defmodule LivebookWeb.Hub.Edit.PersonalComponent do secret_value = if assigns.live_action == :edit_secret do Enum.find_value(secrets, &(&1.name == secret_name and &1.value)) || - raise(NotFoundError, secret: secret_name) + raise(NotFoundError, "could not find secret matching #{inspect(secret_name)}") end {:ok,