2018-06-26 12:18:29 +00:00
|
|
|
// @flow
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
|
2018-06-26 12:18:29 +00:00
|
|
|
import { StateListenerRegistry } from '../base/redux';
|
|
|
|
|
|
|
|
import { setFatalError } from './actions';
|
|
|
|
|
|
|
|
declare var APP: Object;
|
|
|
|
|
2020-04-15 13:13:43 +00:00
|
|
|
/**
|
|
|
|
* List of errors that are not fatal (or handled differently) so then the overlays won't kick in.
|
|
|
|
*/
|
2020-05-20 08:25:31 +00:00
|
|
|
const NON_OVERLAY_ERRORS = [
|
2020-04-15 13:13:43 +00:00
|
|
|
JitsiConferenceErrors.CONFERENCE_ACCESS_DENIED,
|
|
|
|
JitsiConferenceErrors.CONFERENCE_DESTROYED,
|
|
|
|
JitsiConferenceErrors.CONNECTION_ERROR
|
|
|
|
];
|
|
|
|
|
2018-06-26 12:18:29 +00:00
|
|
|
/**
|
|
|
|
* State listener which emits the {@code fatalErrorOccurred} action which works
|
|
|
|
* as a catch all for critical errors which have not been claimed by any other
|
|
|
|
* feature for error recovery (the recoverable flag is not set).
|
|
|
|
*/
|
|
|
|
StateListenerRegistry.register(
|
|
|
|
/* selector */ state => {
|
|
|
|
const { error: conferenceError } = state['features/base/conference'];
|
|
|
|
const { error: configError } = state['features/base/config'];
|
|
|
|
const { error: connectionError } = state['features/base/connection'];
|
|
|
|
|
|
|
|
return configError || connectionError || conferenceError;
|
|
|
|
},
|
|
|
|
/* listener */ (error, { dispatch }) => {
|
|
|
|
error
|
2020-05-20 08:25:31 +00:00
|
|
|
&& NON_OVERLAY_ERRORS.indexOf(error.name) === -1
|
2018-06-26 12:18:29 +00:00
|
|
|
&& typeof error.recoverable === 'undefined'
|
|
|
|
&& dispatch(setFatalError(error));
|
|
|
|
}
|
|
|
|
);
|