mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-19 21:38:13 +08:00
Make NotFoundError reusable
This commit is contained in:
parent
92fa990620
commit
670f099e5e
2 changed files with 4 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue