@@ -117,7 +117,9 @@ import Unison.Server.Backend (ShallowListEntry (..), TypeEntry (..))
117
117
import Unison.Server.Backend qualified as Backend
118
118
import Unison.Server.SearchResultPrime qualified as SR'
119
119
import Unison.Share.Sync.Types qualified as Share (CodeserverTransportError (.. ), GetCausalHashByPathError (.. ), PullError (.. ))
120
+ import Unison.Share.Sync.Types qualified as Sync
120
121
import Unison.Sync.Types qualified as Share
122
+ import Unison.SyncV2.Types qualified as SyncV2
121
123
import Unison.Syntax.DeclPrinter qualified as DeclPrinter
122
124
import Unison.Syntax.HashQualified qualified as HQ (toText , unsafeFromVar )
123
125
import Unison.Syntax.Name qualified as Name (toText )
@@ -2259,8 +2261,9 @@ notifyUser dir = \case
2259
2261
]
2260
2262
Literal message -> pure message
2261
2263
SyncPullError syncErr ->
2262
- -- TODO: Better error message
2263
- pure (P. shown syncErr)
2264
+ case syncErr of
2265
+ Sync. TransportError te -> pure (prettyTransportError te)
2266
+ Sync. SyncError pullErr -> pure (prettyPullV2Error pullErr)
2264
2267
2265
2268
prettyShareError :: ShareError -> Pretty
2266
2269
prettyShareError =
@@ -2280,6 +2283,26 @@ prettyDownloadEntitiesError = \case
2280
2283
Share. DownloadEntitiesProjectNotFound project -> shareProjectNotFound project
2281
2284
Share. DownloadEntitiesEntityValidationFailure err -> prettyEntityValidationFailure err
2282
2285
2286
+ prettyBranchRef :: SyncV2. BranchRef -> Pretty
2287
+ prettyBranchRef (SyncV2. BranchRef txt) = P. blue (P. text txt)
2288
+
2289
+ prettyDownloadEntitiesErrorV2 :: SyncV2. DownloadEntitiesError -> Pretty
2290
+ prettyDownloadEntitiesErrorV2 = \ case
2291
+ SyncV2. DownloadEntitiesNoReadPermission branchRef -> prettyBranchRef branchRef
2292
+ SyncV2. DownloadEntitiesUserNotFound userHandle -> shareUserNotFound (Share. RepoInfo userHandle)
2293
+ SyncV2. DownloadEntitiesProjectNotFound project -> shareProjectNotFound project
2294
+ SyncV2. DownloadEntitiesEntityValidationFailure err -> prettyEntityValidationFailure err
2295
+ SyncV2. DownloadEntitiesInvalidBranchRef msg ref -> prettyInvalidBranchRef msg ref
2296
+
2297
+ prettyInvalidBranchRef :: Text -> SyncV2. BranchRef -> Pretty
2298
+ prettyInvalidBranchRef msg (SyncV2. BranchRef txt) =
2299
+ P. wrap $
2300
+ " The server sent an invalid branch reference."
2301
+ <> " The error was:"
2302
+ <> P. text msg
2303
+ <> " The branch reference was:"
2304
+ <> P. text txt
2305
+
2283
2306
prettyGetCausalHashByPathError :: Share. GetCausalHashByPathError -> Pretty
2284
2307
prettyGetCausalHashByPathError = \ case
2285
2308
Share. GetCausalHashByPathErrorNoReadPermission sharePath -> noReadPermissionForPath sharePath
@@ -2293,6 +2316,38 @@ prettyPullError = \case
2293
2316
Share. PullError'NoHistoryAtPath sharePath ->
2294
2317
P. wrap $ P. text " The server didn't find anything at" <> prettySharePath sharePath
2295
2318
2319
+ prettyPullV2Error :: SyncV2. PullError -> Pretty
2320
+ prettyPullV2Error = \ case
2321
+ SyncV2. PullError'DownloadEntities err -> prettyDownloadEntitiesErrorV2 err
2322
+ SyncV2. PullError'Sync syncErr -> prettySyncErrorV2 syncErr
2323
+
2324
+ prettySyncErrorV2 :: SyncV2. SyncError -> Pretty
2325
+ prettySyncErrorV2 = \ case
2326
+ SyncV2. SyncErrorExpectedResultNotInMain hash ->
2327
+ P. wrap $
2328
+ " The sync finished, but I'm missing an entity I expected."
2329
+ <> " The missing hash is:"
2330
+ <> prettyCausalHash hash
2331
+ SyncV2. SyncErrorDeserializationFailure failure ->
2332
+ P. wrap $
2333
+ " Failed to decode a response from the server."
2334
+ <> " The error was:"
2335
+ <> P. shown failure
2336
+ SyncV2. SyncErrorMissingInitialChunk ->
2337
+ P. wrap " The server didn't send the initial chunk of the response."
2338
+ SyncV2. SyncErrorMisplacedInitialChunk ->
2339
+ P. wrap " The server sent the initial chunk of the response in the wrong place."
2340
+ SyncV2. SyncErrorStreamFailure msg ->
2341
+ P. wrap $
2342
+ " Failed to stream data from the server."
2343
+ <> " The error was:"
2344
+ <> P. text msg
2345
+ SyncV2. SyncErrorUnsupportedVersion version ->
2346
+ P. wrap $
2347
+ " The server sent a response with an unsupported version."
2348
+ <> " The version was:"
2349
+ <> P. shown version
2350
+
2296
2351
prettyUploadEntitiesError :: Share. UploadEntitiesError -> Pretty
2297
2352
prettyUploadEntitiesError = \ case
2298
2353
Share. UploadEntitiesError'EntityValidationFailure validationFailureErr -> prettyEntityValidationFailure validationFailureErr
@@ -2367,10 +2422,10 @@ prettyTransportError = \case
2367
2422
Share. UnexpectedResponse resp ->
2368
2423
unexpectedServerResponse resp
2369
2424
Share. StreamingError err ->
2370
- P. lines
2371
- [ ( " We encountered an error while streaming data from the code server: " <> P. text err),
2372
- P. red (P. text err)
2373
- ]
2425
+ P. lines
2426
+ [ (" We encountered an error while streaming data from the code server: " <> P. text err),
2427
+ P. red (P. text err)
2428
+ ]
2374
2429
2375
2430
unexpectedServerResponse :: Servant. ResponseF LazyByteString. ByteString -> P. Pretty Unison.Util.ColorText. ColorText
2376
2431
unexpectedServerResponse resp =
0 commit comments