Browse Source

ref(base/connection): conferenceFailed error argument

Introduce ConnectionFailedError type.
j8
paweldomas 7 years ago
parent
commit
a9ee5944e1

+ 6
- 1
connection.js View File

102
         /* eslint-enable max-params */
102
         /* eslint-enable max-params */
103
             APP.store.dispatch(
103
             APP.store.dispatch(
104
                 connectionFailed(
104
                 connectionFailed(
105
-                    connection, error, message, credentials, details));
105
+                    connection, {
106
+                        credentials,
107
+                        details,
108
+                        message,
109
+                        name: error
110
+                    }));
106
 
111
 
107
             if (isFatalJitsiConnectionError(error)) {
112
             if (isFatalJitsiConnectionError(error)) {
108
                 connection.removeEventListener(
113
                 connection.removeEventListener(

+ 2
- 5
react/features/authentication/actions.js View File

4
 import { checkIfCanJoin, conferenceLeft } from '../base/conference';
4
 import { checkIfCanJoin, conferenceLeft } from '../base/conference';
5
 import { connectionFailed } from '../base/connection';
5
 import { connectionFailed } from '../base/connection';
6
 import { openDialog } from '../base/dialog';
6
 import { openDialog } from '../base/dialog';
7
+import { set } from '../base/redux';
7
 
8
 
8
 import {
9
 import {
9
     CANCEL_LOGIN,
10
     CANCEL_LOGIN,
89
             && dispatch(
90
             && dispatch(
90
                 connectionFailed(
91
                 connectionFailed(
91
                     passwordRequired,
92
                     passwordRequired,
92
-                    error && error.name,
93
-                    error && error.message,
94
-                    error && error.credentials,
95
-                    error && error.details,
96
-                    /* recoverable */ false));
93
+                    set(error, 'recoverable', false)));
97
     };
94
     };
98
 }
95
 }
99
 
96
 

+ 67
- 32
react/features/base/connection/actions.native.js View File

15
     SET_LOCATION_URL
15
     SET_LOCATION_URL
16
 } from './actionTypes';
16
 } from './actionTypes';
17
 
17
 
18
+/**
19
+ * The error structure passed to the {@link connectionFailed} action.
20
+ *
21
+ * Note there was an intention to make the error resemble an Error instance (to
22
+ * the extent that jitsi-meet needs it).
23
+ */
24
+export type ConnectionFailedError = {
25
+
26
+    /**
27
+     * The invalid credentials that were used to authenticate and the
28
+     * authentication failed.
29
+     */
30
+    credentials?: {
31
+
32
+        /**
33
+         * The XMPP user's ID.
34
+         */
35
+        jid: string,
36
+
37
+        /**
38
+         * The XMPP user's password.
39
+         */
40
+        password: string
41
+    },
42
+
43
+    /**
44
+     * The details about the connection failed event.
45
+     */
46
+    details?: string,
47
+
48
+    /**
49
+     * Error message.
50
+     */
51
+    message?: string,
52
+
53
+    /**
54
+     * One of {@link JitsiConnectionError} constants (defined in
55
+     * lib-jitsi-meet).
56
+     */
57
+    name: string,
58
+
59
+    /**
60
+     * Indicates whether this event is recoverable or not.
61
+     */
62
+    recoverable?: boolean
63
+}
64
+
18
 /**
65
 /**
19
  * Opens new connection.
66
  * Opens new connection.
20
  *
67
  *
89
          * @private
136
          * @private
90
          * @returns {void}
137
          * @returns {void}
91
          */
138
          */
92
-        function _onConnectionFailed(err, msg, credentials) {
139
+        function _onConnectionFailed(
140
+                err: string, msg: string, credentials: Object) {
93
             unsubscribe();
141
             unsubscribe();
94
             console.error('CONNECTION FAILED:', err, msg);
142
             console.error('CONNECTION FAILED:', err, msg);
95
-            dispatch(connectionFailed(connection, err, msg, credentials));
143
+            dispatch(
144
+                connectionFailed(
145
+                    connection, {
146
+                        credentials,
147
+                        name: err,
148
+                        message: msg
149
+                    }
150
+                ));
96
         }
151
         }
97
 
152
 
98
         /**
153
         /**
167
     };
222
     };
168
 }
223
 }
169
 
224
 
170
-/* eslint-disable max-params */
171
-
172
 /**
225
 /**
173
  * Create an action for when the signaling connection could not be created.
226
  * Create an action for when the signaling connection could not be created.
174
  *
227
  *
175
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
228
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
176
- * @param {string} error - Error.
177
- * @param {string} [message] - Error message.
178
- * @param {Object} [credentials] - The invalid credentials that failed
179
- * the authentication.
180
- * @param {Object} [details] - The details about the connection failed event.
181
- * @param {boolean} [recoverable] - Indicates whether this event is recoverable
182
- * or not.
229
+ * @param {ConnectionFailedError} error - Error.
183
  * @public
230
  * @public
184
  * @returns {{
231
  * @returns {{
185
  *     type: CONNECTION_FAILED,
232
  *     type: CONNECTION_FAILED,
186
  *     connection: JitsiConnection,
233
  *     connection: JitsiConnection,
187
- *     error: Object
234
+ *     error: ConnectionFailedError
188
  * }}
235
  * }}
189
  */
236
  */
190
 export function connectionFailed(
237
 export function connectionFailed(
191
         connection: Object,
238
         connection: Object,
192
-        error: string,
193
-        message: ?string,
194
-        credentials: ?Object,
195
-        details: ?Object,
196
-        recoverable: ?boolean) {
239
+        error: ConnectionFailedError) {
240
+    const { credentials } = error;
241
+
242
+    if (credentials && !Object.keys(credentials).length) {
243
+        error.credentials = undefined;
244
+    }
245
+
197
     return {
246
     return {
198
         type: CONNECTION_FAILED,
247
         type: CONNECTION_FAILED,
199
         connection,
248
         connection,
200
-
201
-        // Make the error resemble an Error instance (to the extent that
202
-        // jitsi-meet needs it).
203
-        error: {
204
-            credentials:
205
-                credentials && Object.keys(credentials).length
206
-                    ? credentials
207
-                    : undefined,
208
-            message,
209
-            name: error,
210
-            details,
211
-            recoverable
212
-        }
249
+        error
213
     };
250
     };
214
 }
251
 }
215
 
252
 
216
-/* eslint-enable max-params */
217
-
218
 /**
253
 /**
219
  * Constructs options to be passed to the constructor of {@code JitsiConnection}
254
  * Constructs options to be passed to the constructor of {@code JitsiConnection}
220
  * based on the redux state.
255
  * based on the redux state.

+ 3
- 1
react/features/base/connection/reducer.js View File

13
     SET_LOCATION_URL
13
     SET_LOCATION_URL
14
 } from './actionTypes';
14
 } from './actionTypes';
15
 
15
 
16
+import type { ConnectionFailedError } from './actions.native';
17
+
16
 /**
18
 /**
17
  * Reduces the Redux actions of the feature base/connection.
19
  * Reduces the Redux actions of the feature base/connection.
18
  */
20
  */
100
         state: Object,
102
         state: Object,
101
         { connection, error }: {
103
         { connection, error }: {
102
             connection: Object,
104
             connection: Object,
103
-            error: Object | string
105
+            error: ConnectionFailedError
104
         }) {
106
         }) {
105
 
107
 
106
     // The current (similar to getCurrentConference in
108
     // The current (similar to getCurrentConference in

Loading…
Cancel
Save