feat(errors) Expose errors through Iframe API (#9801)
This commit is contained in:
parent
6537447d7c
commit
7966c8f88f
|
@ -1325,6 +1325,19 @@ class API {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify external application (if API is enabled) that an error occured.
|
||||||
|
*
|
||||||
|
* @param {Object} error - The error.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
notifyError(error: Object) {
|
||||||
|
this._sendEvent({
|
||||||
|
name: 'error',
|
||||||
|
error
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposes the allocated resources.
|
* Disposes the allocated resources.
|
||||||
*
|
*
|
||||||
|
|
|
@ -81,6 +81,7 @@ const events = {
|
||||||
'device-list-changed': 'deviceListChanged',
|
'device-list-changed': 'deviceListChanged',
|
||||||
'display-name-change': 'displayNameChange',
|
'display-name-change': 'displayNameChange',
|
||||||
'email-change': 'emailChange',
|
'email-change': 'emailChange',
|
||||||
|
'error': 'error',
|
||||||
'endpoint-text-message-received': 'endpointTextMessageReceived',
|
'endpoint-text-message-received': 'endpointTextMessageReceived',
|
||||||
'feedback-submitted': 'feedbackSubmitted',
|
'feedback-submitted': 'feedbackSubmitted',
|
||||||
'feedback-prompt-displayed': 'feedbackPromptDisplayed',
|
'feedback-prompt-displayed': 'feedbackPromptDisplayed',
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
|
import {
|
||||||
|
JitsiConferenceErrors,
|
||||||
|
isFatalJitsiConferenceError,
|
||||||
|
isFatalJitsiConnectionError
|
||||||
|
} from '../base/lib-jitsi-meet';
|
||||||
import { StateListenerRegistry } from '../base/redux';
|
import { StateListenerRegistry } from '../base/redux';
|
||||||
|
|
||||||
import { setFatalError } from './actions';
|
import { setFatalError } from './actions';
|
||||||
|
@ -16,6 +20,47 @@ const NON_OVERLAY_ERRORS = [
|
||||||
JitsiConferenceErrors.CONNECTION_ERROR
|
JitsiConferenceErrors.CONNECTION_ERROR
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const ERROR_TYPES = {
|
||||||
|
CONFIG: 'CONFIG',
|
||||||
|
CONNECTION: 'CONNECTION',
|
||||||
|
CONFERENCE: 'CONFERENCE'
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the error type and whether it's fatal or not.
|
||||||
|
*
|
||||||
|
* @param {Function} getState - The redux function for fetching the current state.
|
||||||
|
* @param {Object|string} error - The error to process.
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
const getErrorExtraInfo = (getState, error) => {
|
||||||
|
const state = getState();
|
||||||
|
const { error: conferenceError } = state['features/base/conference'];
|
||||||
|
const { error: configError } = state['features/base/config'];
|
||||||
|
const { error: connectionError } = state['features/base/connection'];
|
||||||
|
|
||||||
|
if (error === conferenceError) {
|
||||||
|
return {
|
||||||
|
type: ERROR_TYPES.CONFERENCE,
|
||||||
|
isFatal: isFatalJitsiConferenceError(error.name || error)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error === configError) {
|
||||||
|
return {
|
||||||
|
type: ERROR_TYPES.CONFIG,
|
||||||
|
isFatal: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error === connectionError) {
|
||||||
|
return {
|
||||||
|
type: ERROR_TYPES.CONNECTION,
|
||||||
|
isFatal: isFatalJitsiConnectionError(error.name || error)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* State listener which emits the {@code fatalErrorOccurred} action which works
|
* 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
|
* as a catch all for critical errors which have not been claimed by any other
|
||||||
|
@ -29,10 +74,22 @@ StateListenerRegistry.register(
|
||||||
|
|
||||||
return configError || connectionError || conferenceError;
|
return configError || connectionError || conferenceError;
|
||||||
},
|
},
|
||||||
/* listener */ (error, { dispatch }) => {
|
/* listener */ (error, { dispatch, getState }) => {
|
||||||
error
|
if (!error) {
|
||||||
&& NON_OVERLAY_ERRORS.indexOf(error.name) === -1
|
return;
|
||||||
&& typeof error.recoverable === 'undefined'
|
}
|
||||||
&& dispatch(setFatalError(error));
|
|
||||||
|
if (typeof APP !== 'undefined') {
|
||||||
|
const parsedError = typeof error === 'string' ? { name: error } : error;
|
||||||
|
|
||||||
|
APP.API.notifyError({
|
||||||
|
...parsedError,
|
||||||
|
...getErrorExtraInfo(getState, error)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NON_OVERLAY_ERRORS.indexOf(error.name) === -1 && typeof error.recoverable === 'undefined') {
|
||||||
|
dispatch(setFatalError(error));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue