-
The URL generation logic is inside the defmodule SampleAppWeb.OidccController do
use SampleAppWeb, :controller
plug Oidcc.Plug.Authorize .....
plug Oidcc.Plug.AuthorizationCallback, .......
@doc false
def callback_uri, do: url(~p"/oidcc/callback")
def authorize(conn, _params), do: conn
end However if the server fails to generate a URL due to an error I only see an error defmodule SampleAppWeb.OidccController do
use SampleAppWeb, :controller
plug Oidcc.Plug.Authorize .....
plug Oidcc.Plug.AuthorizationCallback, .......
@doc false
def callback_uri, do: url(~p"/oidcc/callback")
def authorize(conn, _params), do: conn
def callback(%Plug.Conn{private: %{
Oidcc.Plug.AuthorizationCallback => {:error, reason}
}} = conn, _params) do
conn
|> put_status(400)
|> render(:error, reason: reason)
end
end Here is the line that throws the error oidcc_plug/lib/oidcc/plug/authorize.ex Line 148 in d76a47d QuestionHow can I log the details of the error to my logger? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The current solution stores the The reason for this is that some errors contain confidential data like client secrets and they should not be logged directly. We should however add some more details. We can for example add the first element of the error tuple to the error message. Based on your slack message, it would mention that there was an HTTP error behind the scenes. Since I already have an issue open for revamping the error handling, I added this to the description. #26 To get all information out of the error, you should be able to implement a custom error view in phoenix, where you have access to the whole struct. |
Beta Was this translation helpful? Give feedback.
The current solution stores the
reason
in the error struct, but does not add it to the error message.The reason for this is that some errors contain confidential data like client secrets and they should not be logged directly.
We should however add some more details. We can for example add the first element of the error tuple to the error message. Based on your slack message, it would mention that there was an HTTP error behind the scenes.
Since I already have an issue open for revamping the error handling, I added this to the description. #26
To get all information out of the error, you should be able to implement a custom error view in phoenix, where you have access to the whole struct.