@@ -138,6 +138,7 @@ import Unison.Term (Term)
138
138
import Unison.Term qualified as Term
139
139
import Unison.Type (Type )
140
140
import Unison.UnisonFile qualified as UF
141
+ import Unison.Util.ColorText qualified
141
142
import Unison.Util.Conflicted (Conflicted (.. ))
142
143
import Unison.Util.Defn (Defn (.. ))
143
144
import Unison.Util.Defns (Defns (.. ))
@@ -971,7 +972,6 @@ notifyUser dir = \case
971
972
-- defs in the codebase. In some cases it's fine for bindings to
972
973
-- shadow codebase names, but you don't want it to capture them in
973
974
-- the decompiled output.
974
-
975
975
let prettyBindings =
976
976
P. bracket . P. lines $
977
977
P. wrap " The watch expression(s) reference these definitions:"
@@ -1771,16 +1771,16 @@ notifyUser dir = \case
1771
1771
<> P. newline
1772
1772
<> P. indentN 2 (P. pshown response)
1773
1773
Servant. FailureResponse request response ->
1774
- P. wrap " Oops, I received an unexpected status code from the server. "
1774
+ unexpectedServerResponse response
1775
1775
<> P. newline
1776
1776
<> P. newline
1777
- <> P. wrap " Here is the request. "
1777
+ <> P. wrap " Here is the request: "
1778
1778
<> P. newline
1779
1779
<> P. newline
1780
1780
<> P. indentN 2 (P. pshown request)
1781
1781
<> P. newline
1782
1782
<> P. newline
1783
- <> P. wrap " Here is the full response. "
1783
+ <> P. wrap " Here is the full response: "
1784
1784
<> P. newline
1785
1785
<> P. newline
1786
1786
<> P. indentN 2 (P. pshown response)
@@ -2362,21 +2362,24 @@ prettyTransportError = \case
2362
2362
Share. RateLimitExceeded -> " Rate limit exceeded, please try again later."
2363
2363
Share. Timeout -> " The code server timed-out when responding to your request. Please try again later or report an issue if the problem persists."
2364
2364
Share. UnexpectedResponse resp ->
2365
- (P. lines . catMaybes)
2366
- [ Just
2367
- ( " The server sent a "
2368
- <> P. red (P. shown (Http. statusCode (Servant. responseStatusCode resp)))
2369
- <> " that we didn't expect."
2370
- ),
2371
- let body = Text. decodeUtf8 (LazyByteString. toStrict (Servant. responseBody resp))
2372
- in if Text. null body then Nothing else Just (P. newline <> " Response body: " <> P. text body),
2373
- responseRequestId resp <&> \ responseId -> P. newline <> " Request ID: " <> P. blue (P. text responseId)
2374
- ]
2375
- where
2376
- -- Dig the request id out of a response header.
2377
- responseRequestId :: Servant. Response -> Maybe Text
2378
- responseRequestId =
2379
- fmap Text. decodeUtf8 . List. lookup " X-RequestId" . Foldable. toList @ Seq . Servant. responseHeaders
2365
+ unexpectedServerResponse resp
2366
+
2367
+ unexpectedServerResponse :: Servant. ResponseF LazyByteString. ByteString -> P. Pretty Unison.Util.ColorText. ColorText
2368
+ unexpectedServerResponse resp =
2369
+ (P. lines . catMaybes)
2370
+ [ Just
2371
+ ( " I received an unexpected status code from the server: "
2372
+ <> P. red (P. shown (Http. statusCode (Servant. responseStatusCode resp)))
2373
+ ),
2374
+ let body = Text. decodeUtf8 (LazyByteString. toStrict (Servant. responseBody resp))
2375
+ in if Text. null body then Nothing else Just (P. newline <> " Response body: " <> P. text body),
2376
+ responseRequestId resp <&> \ responseId -> P. newline <> " Request ID: " <> P. blue (P. text responseId)
2377
+ ]
2378
+
2379
+ -- | Dig the request id out of a response header.
2380
+ responseRequestId :: Servant. Response -> Maybe Text
2381
+ responseRequestId =
2382
+ fmap Text. decodeUtf8 . List. lookup " X-RequestId" . Foldable. toList @ Seq . Servant. responseHeaders
2380
2383
2381
2384
prettyEntityType :: Share. EntityType -> Pretty
2382
2385
prettyEntityType = \ case
0 commit comments