|
@@ -1,6 +1,10 @@
|
1
|
1
|
// @flow
|
2
|
2
|
|
3
|
|
-import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
|
|
3
|
+import {
|
|
4
|
+ JitsiConferenceErrors,
|
|
5
|
+ isFatalJitsiConferenceError,
|
|
6
|
+ isFatalJitsiConnectionError
|
|
7
|
+} from '../base/lib-jitsi-meet';
|
4
|
8
|
import { StateListenerRegistry } from '../base/redux';
|
5
|
9
|
|
6
|
10
|
import { setFatalError } from './actions';
|
|
@@ -16,6 +20,47 @@ const NON_OVERLAY_ERRORS = [
|
16
|
20
|
JitsiConferenceErrors.CONNECTION_ERROR
|
17
|
21
|
];
|
18
|
22
|
|
|
23
|
+const ERROR_TYPES = {
|
|
24
|
+ CONFIG: 'CONFIG',
|
|
25
|
+ CONNECTION: 'CONNECTION',
|
|
26
|
+ CONFERENCE: 'CONFERENCE'
|
|
27
|
+};
|
|
28
|
+
|
|
29
|
+/**
|
|
30
|
+ * Gets the error type and whether it's fatal or not.
|
|
31
|
+ *
|
|
32
|
+ * @param {Function} getState - The redux function for fetching the current state.
|
|
33
|
+ * @param {Object|string} error - The error to process.
|
|
34
|
+ * @returns {void}
|
|
35
|
+ */
|
|
36
|
+const getErrorExtraInfo = (getState, error) => {
|
|
37
|
+ const state = getState();
|
|
38
|
+ const { error: conferenceError } = state['features/base/conference'];
|
|
39
|
+ const { error: configError } = state['features/base/config'];
|
|
40
|
+ const { error: connectionError } = state['features/base/connection'];
|
|
41
|
+
|
|
42
|
+ if (error === conferenceError) {
|
|
43
|
+ return {
|
|
44
|
+ type: ERROR_TYPES.CONFERENCE,
|
|
45
|
+ isFatal: isFatalJitsiConferenceError(error.name || error)
|
|
46
|
+ };
|
|
47
|
+ }
|
|
48
|
+
|
|
49
|
+ if (error === configError) {
|
|
50
|
+ return {
|
|
51
|
+ type: ERROR_TYPES.CONFIG,
|
|
52
|
+ isFatal: true
|
|
53
|
+ };
|
|
54
|
+ }
|
|
55
|
+
|
|
56
|
+ if (error === connectionError) {
|
|
57
|
+ return {
|
|
58
|
+ type: ERROR_TYPES.CONNECTION,
|
|
59
|
+ isFatal: isFatalJitsiConnectionError(error.name || error)
|
|
60
|
+ };
|
|
61
|
+ }
|
|
62
|
+};
|
|
63
|
+
|
19
|
64
|
/**
|
20
|
65
|
* State listener which emits the {@code fatalErrorOccurred} action which works
|
21
|
66
|
* as a catch all for critical errors which have not been claimed by any other
|
|
@@ -29,10 +74,22 @@ StateListenerRegistry.register(
|
29
|
74
|
|
30
|
75
|
return configError || connectionError || conferenceError;
|
31
|
76
|
},
|
32
|
|
- /* listener */ (error, { dispatch }) => {
|
33
|
|
- error
|
34
|
|
- && NON_OVERLAY_ERRORS.indexOf(error.name) === -1
|
35
|
|
- && typeof error.recoverable === 'undefined'
|
36
|
|
- && dispatch(setFatalError(error));
|
|
77
|
+ /* listener */ (error, { dispatch, getState }) => {
|
|
78
|
+ if (!error) {
|
|
79
|
+ return;
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ if (typeof APP !== 'undefined') {
|
|
83
|
+ const parsedError = typeof error === 'string' ? { name: error } : error;
|
|
84
|
+
|
|
85
|
+ APP.API.notifyError({
|
|
86
|
+ ...parsedError,
|
|
87
|
+ ...getErrorExtraInfo(getState, error)
|
|
88
|
+ });
|
|
89
|
+ }
|
|
90
|
+
|
|
91
|
+ if (NON_OVERLAY_ERRORS.indexOf(error.name) === -1 && typeof error.recoverable === 'undefined') {
|
|
92
|
+ dispatch(setFatalError(error));
|
|
93
|
+ }
|
37
|
94
|
}
|
38
|
95
|
);
|