I recently ran into an issue with some code I wrote. I wanted to pattern match on any errors when generating the authorize_url and was getting a KeyError that wouldn't let me hit the error clause below. I finally noticed I had a typo in my :site configuration so it was not able to connect to the site and an error was being thrown.
case ProjectWeb.Strategy.authorize_url(oidc_config) do
{:ok, %{url: url, session_params: %{state: state, nonce: nonce}}} ->
conn
|> put_session("state", state)
|> put_session("nonce", nonce)
|> redirect(external: url)
# Was getting a warning this would never match
{:error, _reason} ->
# KeyError would not let this logic execute
redirect(conn, to: "/")
end
This PR addresses what was causing the KeyError to occur and fixes the typespec to allow the error clause above to work without the nice squiggly yellow warning line in my editor.
I recently ran into an issue with some code I wrote. I wanted to pattern match on any errors when generating the authorize_url and was getting a KeyError that wouldn't let me hit the error clause below. I finally noticed I had a typo in my
:site
configuration so it was not able to connect to the site and an error was being thrown.This PR addresses what was causing the KeyError to occur and fixes the typespec to allow the error clause above to work without the nice squiggly yellow warning line in my editor.