Skip to content

Commit ca4bb33

Browse files
committed
More common sync types
1 parent ab2297c commit ca4bb33

File tree

1 file changed

+24
-1
lines changed
  • unison-share-api/src/Unison/SyncV3

1 file changed

+24
-1
lines changed

unison-share-api/src/Unison/SyncV3/Types.hs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Unison.SyncV3.Types
1313
)
1414
where
1515

16-
import Unison.SyncCommon.Types
1716
import Codec.Serialise (Serialise)
1817
import Codec.Serialise qualified as CBOR
1918
import Control.Lens hiding ((.=))
@@ -34,6 +33,7 @@ import Unison.Hash32 (Hash32)
3433
import Unison.Prelude (tShow)
3534
import Unison.Server.Orphans ()
3635
import Unison.Sqlite qualified as Sqlite
36+
import Unison.SyncCommon.Types
3737
import Unison.Util.Servant.CBOR qualified as CBOR
3838

3939
data InitMsg authedHash = InitMsg
@@ -159,6 +159,11 @@ data SyncError
159159
| -- The caller asked for a Hash they shouldn't have access to.
160160
ForbiddenEntityRequest (Set (EntityKind, Hash32))
161161
| ConnectionError Text
162+
| ProjectNotFound BranchRef
163+
| UserNotFound BranchRef
164+
| NoReadPermission BranchRef
165+
| HashJWTVerificationError Text
166+
| InvalidBranchRef Text BranchRef
162167
deriving (Show, Eq)
163168

164169
-- | Roundtrip test:
@@ -183,6 +188,16 @@ instance CBOR.Serialise SyncError where
183188
CBOR.encode (3 :: Int) <> CBOR.encode hashes
184189
ConnectionError err ->
185190
CBOR.encode (4 :: Int) <> CBOR.encode err
191+
ProjectNotFound branchRef ->
192+
CBOR.encode (5 :: Int) <> CBOR.encode branchRef
193+
UserNotFound branchRef ->
194+
CBOR.encode (6 :: Int) <> CBOR.encode branchRef
195+
NoReadPermission branchRef ->
196+
CBOR.encode (7 :: Int) <> CBOR.encode branchRef
197+
HashJWTVerificationError err ->
198+
CBOR.encode (8 :: Int) <> CBOR.encode err
199+
InvalidBranchRef err branchRef ->
200+
CBOR.encode (9 :: Int) <> CBOR.encode err <> CBOR.encode branchRef
186201

187202
decode = do
188203
tag <- CBOR.decode @Int
@@ -196,6 +211,14 @@ instance CBOR.Serialise SyncError where
196211
4 -> do
197212
err <- CBOR.decode @Text
198213
pure $ ConnectionError err
214+
5 -> ProjectNotFound <$> CBOR.decode
215+
6 -> UserNotFound <$> CBOR.decode
216+
7 -> NoReadPermission <$> CBOR.decode
217+
8 -> HashJWTVerificationError <$> CBOR.decode
218+
9 -> do
219+
err <- CBOR.decode @Text
220+
branchRef <- CBOR.decode @BranchRef
221+
pure $ InvalidBranchRef err branchRef
199222
_ -> fail $ "Unknown SyncError tag: " <> show tag
200223

201224
-- A message sent from the emitter to the downloader.

0 commit comments

Comments
 (0)