Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/polysemy-errors
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Introduce fine-grained error types and polysemy error effects in Galley.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ data FederationError
| FederationNotImplemented
| FederationNotConfigured
| FederationCallFailure FederationClientFailure
| FederationUnexpectedBody Text
deriving (Show, Eq, Typeable)

instance Exception FederationError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ federationErrorToWai (FederationCallFailure failure) = addErrorData $
Wai.federrPath = T.decodeUtf8 (fedFailPath failure)
}
}
federationErrorToWai (FederationUnexpectedBody s) = federationUnexpectedBody s

noFederationStatus :: Status
noFederationStatus = status403
Expand Down
3 changes: 1 addition & 2 deletions libs/wire-api/src/Wire/API/Conversation/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import Wire.API.Conversation.Role
import Wire.API.Event.Conversation
import Wire.API.Util.Aeson (CustomEncoded (..))

-- | An update to a conversation, including addition and removal of members.
-- Used to send notifications to users and to remote backends.
-- | A sum type consisting of all possible conversation actions.
data ConversationAction
= ConversationActionAddMembers (NonEmpty (Qualified UserId)) RoleName
| ConversationActionRemoveMembers (NonEmpty (Qualified UserId))
Expand Down
9 changes: 6 additions & 3 deletions libs/wire-api/src/Wire/API/ErrorDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,13 @@ noIdentity n = ErrorDescription (Text.pack (symbolVal (Proxy @desc)) <> " (code

type OperationDenied = ErrorDescription 403 "operation-denied" "Insufficient permissions"

operationDenied :: Show perm => perm -> OperationDenied
operationDenied p =
operationDeniedSpecialized :: String -> OperationDenied
operationDeniedSpecialized p =
ErrorDescription $
"Insufficient permissions (missing " <> Text.pack (show p) <> ")"
"Insufficient permissions (missing " <> Text.pack p <> ")"

operationDenied :: Show perm => perm -> OperationDenied
operationDenied = operationDeniedSpecialized . show

type NotATeamMember = ErrorDescription 403 "no-team-member" "Requesting user is not a team member"

Expand Down
3 changes: 2 additions & 1 deletion services/galley/galley.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 7c30fbe05e0beac371abdaab802319d909686c98a1b133508c984e021b2999ba
-- hash: 6f378c75d7938aa5f221f136049c8ca98f63e7ae682e0035fb912f3917cfd1b1

name: galley
version: 0.83.0
Expand All @@ -25,6 +25,7 @@ flag static
library
exposed-modules:
Galley.API
Galley.API.Action
Galley.API.Clients
Galley.API.Create
Galley.API.CustomBackend
Expand Down
Loading