You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,8 +11,6 @@ public let errorDomain = "AblyChatErrorDomain"
11
11
The error codes for errors in the ``errorDomain`` error domain.
12
12
*/
13
13
publicenumErrorCode:Int{
14
-
case nonspecific =40000
15
-
16
14
/// ``Rooms.get(roomID:options:)`` was called with a different set of room options than was used on a previous call. You must first release the existing room instance using ``Rooms.release(roomID:)``.
17
15
///
18
16
/// TODO this code is a guess, revisit in https://github.com/ably-labs/ably-chat-swift/issues/32
@@ -36,30 +34,118 @@ public enum ErrorCode: Int {
36
34
37
35
case roomInInvalidState =102_107
38
36
37
+
/// Has a case for each of the ``ErrorCode`` cases that imply a fixed status code.
38
+
internalenumCaseThatImpliesFixedStatusCode{
39
+
case inconsistentRoomOptions
40
+
case messagesAttachmentFailed
41
+
case presenceAttachmentFailed
42
+
case reactionsAttachmentFailed
43
+
case occupancyAttachmentFailed
44
+
case typingAttachmentFailed
45
+
case messagesDetachmentFailed
46
+
case presenceDetachmentFailed
47
+
case reactionsDetachmentFailed
48
+
case occupancyDetachmentFailed
49
+
case typingDetachmentFailed
50
+
case roomInFailedState
51
+
case roomIsReleasing
52
+
case roomIsReleased
53
+
54
+
internalvartoNumericErrorCode:ErrorCode{
55
+
switchself{
56
+
case.inconsistentRoomOptions:
57
+
.inconsistentRoomOptions
58
+
case.messagesAttachmentFailed:
59
+
.messagesAttachmentFailed
60
+
case.presenceAttachmentFailed:
61
+
.presenceAttachmentFailed
62
+
case.reactionsAttachmentFailed:
63
+
.reactionsAttachmentFailed
64
+
case.occupancyAttachmentFailed:
65
+
.occupancyAttachmentFailed
66
+
case.typingAttachmentFailed:
67
+
.typingAttachmentFailed
68
+
case.messagesDetachmentFailed:
69
+
.messagesDetachmentFailed
70
+
case.presenceDetachmentFailed:
71
+
.presenceDetachmentFailed
72
+
case.reactionsDetachmentFailed:
73
+
.reactionsDetachmentFailed
74
+
case.occupancyDetachmentFailed:
75
+
.occupancyDetachmentFailed
76
+
case.typingDetachmentFailed:
77
+
.typingDetachmentFailed
78
+
case.roomInFailedState:
79
+
.roomInFailedState
80
+
case.roomIsReleasing:
81
+
.roomIsReleasing
82
+
case.roomIsReleased:
83
+
.roomIsReleased
84
+
}
85
+
}
86
+
87
+
/// The ``ARTErrorInfo.statusCode`` that should be returned for this error.
88
+
internalvarstatusCode:Int{
89
+
// These status codes are taken from the "Chat-specific Error Codes" section of the spec.
90
+
switchself{
91
+
case.inconsistentRoomOptions,
92
+
.roomInFailedState,
93
+
.roomIsReleasing,
94
+
.roomIsReleased:
95
+
400
96
+
case
97
+
.messagesAttachmentFailed,
98
+
.presenceAttachmentFailed,
99
+
.reactionsAttachmentFailed,
100
+
.occupancyAttachmentFailed,
101
+
.typingAttachmentFailed,
102
+
.messagesDetachmentFailed,
103
+
.presenceDetachmentFailed,
104
+
.reactionsDetachmentFailed,
105
+
.occupancyDetachmentFailed,
106
+
.typingDetachmentFailed:
107
+
500
108
+
}
109
+
}
110
+
}
111
+
112
+
/// Has a case for each of the ``ErrorCode`` cases that do not imply a fixed status code.
113
+
internalenumCaseThatImpliesVariableStatusCode{
114
+
case roomInInvalidState
115
+
116
+
internalvartoNumericErrorCode:ErrorCode{
117
+
switchself{
118
+
case.roomInInvalidState:
119
+
.roomInInvalidState
120
+
}
121
+
}
122
+
}
123
+
}
124
+
125
+
/**
126
+
* Represents a case of ``ErrorCode`` plus a status code.
127
+
*/
128
+
internalenumErrorCodeAndStatusCode{
129
+
case fixedStatusCode(ErrorCode.CaseThatImpliesFixedStatusCode)
130
+
case variableStatusCode(ErrorCode.CaseThatImpliesVariableStatusCode, statusCode:Int)
131
+
132
+
/// The ``ARTErrorInfo.code`` that should be returned for this error.
133
+
internalvarcode:ErrorCode{
134
+
switchself{
135
+
caselet.fixedStatusCode(code):
136
+
code.toNumericErrorCode
137
+
caselet.variableStatusCode(code, _):
138
+
code.toNumericErrorCode
139
+
}
140
+
}
141
+
39
142
/// The ``ARTErrorInfo.statusCode`` that should be returned for this error.
40
143
internalvarstatusCode:Int{
41
-
// These status codes are taken from the "Chat-specific Error Codes" section of the spec.
42
144
switchself{
43
-
case.nonspecific,
44
-
.inconsistentRoomOptions,
45
-
.roomInFailedState,
46
-
.roomIsReleasing,
47
-
.roomIsReleased:
48
-
400
49
-
case
50
-
.messagesAttachmentFailed,
51
-
.presenceAttachmentFailed,
52
-
.reactionsAttachmentFailed,
53
-
.occupancyAttachmentFailed,
54
-
.typingAttachmentFailed,
55
-
.messagesDetachmentFailed,
56
-
.presenceDetachmentFailed,
57
-
.reactionsDetachmentFailed,
58
-
.occupancyDetachmentFailed,
59
-
.typingDetachmentFailed,
60
-
// CHA-RL9c
61
-
.roomInInvalidState:
62
-
500
145
+
caselet.fixedStatusCode(code):
146
+
code.statusCode
147
+
caselet.variableStatusCode(_, statusCode):
148
+
statusCode
63
149
}
64
150
}
65
151
}
@@ -77,51 +163,50 @@ internal enum ChatError {
77
163
case roomIsReleasing
78
164
case roomIsReleased
79
165
case presenceOperationRequiresRoomAttach(feature:RoomFeature)
80
-
case presenceOperationDisallowedForCurrentRoomStatus(feature:RoomFeature)
81
-
case roomInInvalidState(cause:ARTErrorInfo?)
166
+
case roomTransitionedToInvalidStateForPresenceOperation(cause:ARTErrorInfo?)
82
167
83
-
/// The ``ARTErrorInfo.code`` that should be returned for this error.
// TODO: copied and pasted from implementation of -[ARTErrorInfo createWithCode:status:message:requestId:] because there’s no way to pass domain; revisit in https://github.com/ably-labs/ably-chat-swift/issues/32. Also the ARTErrorInfoStatusCode variable in ably-cocoa is not public.
// TODO: This is kind of an implementation detail (that NSUnderlyingErrorKey is what populates `cause`); consider documenting in ably-cocoa as part of https://github.com/ably-labs/ably-chat-swift/issues/32.
/// Waits until we can perform presence operations on the contributors of this room without triggering an implicit attach.
43
43
///
44
-
/// Implements the checks described by CHA-PR3d, CHA-PR3e, CHA-PR3f, and CHA-PR3g (and similar ones described by other functionality that performs contributor presence operations). Namely:
44
+
/// Implements the checks described by CHA-PR3d, CHA-PR3e, and CHA-PR3h (and similar ones described by other functionality that performs contributor presence operations). Namely:
45
45
///
46
-
/// - CHA-RL9, which is invoked by CHA-PR3d, CHA-PR10d, CHA-PR6c, CHA-T2c: If the room is in the ATTACHING status, it waits for the next room status change. If the new status is ATTACHED, it returns. Else, it throws an `ARTErrorInfo` derived from ``ChatError.roomInInvalidState(cause:)``.
47
-
/// - CHA-PR3e, CHA-PR11e, CHA-PR6d, CHA-T2d: If the room is in the ATTACHED status, it returns immediately.
48
-
/// - CHA-PR3f, CHA-PR11f, CHA-PR6e, CHA-T2e: If the room is in the DETACHED status, it throws an `ARTErrorInfo` derived from ``ChatError.presenceOperationRequiresRoomAttach(feature:)``.
49
-
/// - // CHA-PR3g, CHA-PR11g, CHA-PR6f, CHA-T2f: If the room is in any other status, it throws an `ARTErrorInfo` derived from ``ChatError.presenceOperationDisallowedForCurrentRoomStatus(feature:)``.
46
+
/// - CHA-RL9, which is invoked by CHA-PR3d, CHA-PR10d, CHA-PR6c, CHA-T2c: If the room is in the ATTACHING status, it waits for the next room status change. If the new status is ATTACHED, it returns. Else, it throws an `ARTErrorInfo` derived from ``ChatError.roomTransitionedToInvalidStateForPresenceOperation(cause:)``.
47
+
/// - CHA-PR3e, CHA-PR10e, CHA-PR6d, CHA-T2d: If the room is in the ATTACHED status, it returns immediately.
48
+
/// - CHA-PR3h, CHA-PR10h, CHA-PR6h, CHA-T2g: If the room is in any other status, it throws an `ARTErrorInfo` derived from ``ChatError.presenceOperationRequiresRoomAttach(feature:)``.
50
49
///
51
50
/// - Parameters:
52
51
/// - requester: The room feature that wishes to perform a presence operation. This is only used for customising the message of the thrown error.
Copy file name to clipboardExpand all lines: Sources/AblyChat/RoomLifecycleManager.swift
+4-7Lines changed: 4 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1225,17 +1225,14 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor
1225
1225
// TODO: decide what to do if nextRoomStatusChange is nil; I believe that this will happen if the current Task is cancelled. For now, will just treat it as an invalid status change. Handle it properly in https://github.com/ably-labs/ably-chat-swift/issues/29
0 commit comments