Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: show more info about connection errors in output #4621

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 14 additions & 8 deletions unison-cli/src/Unison/CommandLine/OutputMessages.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1960,12 +1960,18 @@ notifyUser dir = \case
ServantClientError err ->
pure case err of
Servant.ConnectionError exception ->
P.wrap $
fromMaybe "Something went wrong with the connection. Try again?" do
case ServantClientUtils.classifyConnectionError exception of
ServantClientUtils.ConnectionError'Offline -> Just "You appear to be offline."
ServantClientUtils.ConnectionError'SomethingElse _ -> Nothing
ServantClientUtils.ConnectionError'SomethingEntirelyUnexpected _ -> Nothing
case ServantClientUtils.classifyConnectionError exception of
ServantClientUtils.ConnectionError'Offline -> P.wrap "You appear to be offline."
ServantClientUtils.ConnectionError'SomethingElse content ->
P.wrap "Oops, I encountered an unexpected exception from the server."
<> P.newline
<> P.newline
<> P.indentN 2 (P.pshown content)
ServantClientUtils.ConnectionError'SomethingEntirelyUnexpected _ ->
P.wrap "Oops, I encountered an unexpected exception from the server."
<> P.newline
<> P.newline
<> P.indentN 2 (P.pshown exception)
Servant.DecodeFailure message response ->
P.wrap "Huh, I failed to decode a response from the server."
<> P.newline
Expand Down Expand Up @@ -2700,7 +2706,7 @@ renderEditConflicts ppe Patch {..} = do
then "deprecated and also replaced with"
else "replaced with"
)
`P.hang` P.lines replacements
`P.hang` P.lines replacements
formatTermEdits ::
(Reference.TermReference, Set TermEdit.TermEdit) ->
Numbered Pretty
Expand All @@ -2715,7 +2721,7 @@ renderEditConflicts ppe Patch {..} = do
then "deprecated and also replaced with"
else "replaced with"
)
`P.hang` P.lines replacements
`P.hang` P.lines replacements
formatConflict ::
Either
(Reference, Set TypeEdit.TypeEdit)
Expand Down