Prior to this commit, some errors would be thrown (missing parameter, invalid
state, incorrect approot) while others would be handled via the
set-message-redirect approach (handshake failure, fetch-token failure, etc).
This commit consolidates all of these cases into a single DispatchError type,
and then uses MonadError (concretely ExceptT) to capture them all and handle
them in one place ourselves.
It then updates that handling to:
Use onErrorHtml
onErrorHtml will, by default, set-message-redirect. That make this behavior
neutral for users running defaults. For users that have customized this, it
will be an improvement that all our error cases now respect it.
Provided a JSON representation of errors
Attach a random correlation identifier
The last two were just nice-to-haves that were cheap to add once the code was in
this state.
Note that the use of MonadError requires a potentially "bad" orphan
MonadUnliftIO instance for ExceptT, but I'd like to see that instance become
a reality and think it needs some real-world experimentation to get there, so
here I am.
Prior to this commit, some errors would be thrown (missing parameter, invalid state, incorrect approot) while others would be handled via the set-message-redirect approach (handshake failure, fetch-token failure, etc).
This commit consolidates all of these cases into a single
DispatchError
type, and then usesMonadError
(concretelyExceptT
) to capture them all and handle them in one place ourselves.It then updates that handling to:
Use
onErrorHtml
onErrorHtml
will, by default, set-message-redirect. That make this behavior neutral for users running defaults. For users that have customized this, it will be an improvement that all our error cases now respect it.Provided a JSON representation of errors
Attach a random correlation identifier
The last two were just nice-to-haves that were cheap to add once the code was in this state.
Note that the use of
MonadError
requires a potentially "bad" orphanMonadUnliftIO
instance forExceptT
, but I'd like to see that instance become a reality and think it needs some real-world experimentation to get there, so here I am.