ref(base/connection): conferenceFailed error argument
Introduce ConnectionFailedError type.
This commit is contained in:
parent
36ecc99b5b
commit
a9ee5944e1
|
@ -102,7 +102,12 @@ function connect(id, password, roomName) {
|
||||||
/* eslint-enable max-params */
|
/* eslint-enable max-params */
|
||||||
APP.store.dispatch(
|
APP.store.dispatch(
|
||||||
connectionFailed(
|
connectionFailed(
|
||||||
connection, error, message, credentials, details));
|
connection, {
|
||||||
|
credentials,
|
||||||
|
details,
|
||||||
|
message,
|
||||||
|
name: error
|
||||||
|
}));
|
||||||
|
|
||||||
if (isFatalJitsiConnectionError(error)) {
|
if (isFatalJitsiConnectionError(error)) {
|
||||||
connection.removeEventListener(
|
connection.removeEventListener(
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { appNavigate } from '../app';
|
||||||
import { checkIfCanJoin, conferenceLeft } from '../base/conference';
|
import { checkIfCanJoin, conferenceLeft } from '../base/conference';
|
||||||
import { connectionFailed } from '../base/connection';
|
import { connectionFailed } from '../base/connection';
|
||||||
import { openDialog } from '../base/dialog';
|
import { openDialog } from '../base/dialog';
|
||||||
|
import { set } from '../base/redux';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CANCEL_LOGIN,
|
CANCEL_LOGIN,
|
||||||
|
@ -89,11 +90,7 @@ export function cancelLogin() {
|
||||||
&& dispatch(
|
&& dispatch(
|
||||||
connectionFailed(
|
connectionFailed(
|
||||||
passwordRequired,
|
passwordRequired,
|
||||||
error && error.name,
|
set(error, 'recoverable', false)));
|
||||||
error && error.message,
|
|
||||||
error && error.credentials,
|
|
||||||
error && error.details,
|
|
||||||
/* recoverable */ false));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,53 @@ import {
|
||||||
SET_LOCATION_URL
|
SET_LOCATION_URL
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error structure passed to the {@link connectionFailed} action.
|
||||||
|
*
|
||||||
|
* Note there was an intention to make the error resemble an Error instance (to
|
||||||
|
* the extent that jitsi-meet needs it).
|
||||||
|
*/
|
||||||
|
export type ConnectionFailedError = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The invalid credentials that were used to authenticate and the
|
||||||
|
* authentication failed.
|
||||||
|
*/
|
||||||
|
credentials?: {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XMPP user's ID.
|
||||||
|
*/
|
||||||
|
jid: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The XMPP user's password.
|
||||||
|
*/
|
||||||
|
password: string
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details about the connection failed event.
|
||||||
|
*/
|
||||||
|
details?: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error message.
|
||||||
|
*/
|
||||||
|
message?: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One of {@link JitsiConnectionError} constants (defined in
|
||||||
|
* lib-jitsi-meet).
|
||||||
|
*/
|
||||||
|
name: string,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this event is recoverable or not.
|
||||||
|
*/
|
||||||
|
recoverable?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens new connection.
|
* Opens new connection.
|
||||||
*
|
*
|
||||||
|
@ -89,10 +136,18 @@ export function connect(id: ?string, password: ?string) {
|
||||||
* @private
|
* @private
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function _onConnectionFailed(err, msg, credentials) {
|
function _onConnectionFailed(
|
||||||
|
err: string, msg: string, credentials: Object) {
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
console.error('CONNECTION FAILED:', err, msg);
|
console.error('CONNECTION FAILED:', err, msg);
|
||||||
dispatch(connectionFailed(connection, err, msg, credentials));
|
dispatch(
|
||||||
|
connectionFailed(
|
||||||
|
connection, {
|
||||||
|
credentials,
|
||||||
|
name: err,
|
||||||
|
message: msg
|
||||||
|
}
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -167,54 +222,34 @@ export function connectionEstablished(connection: Object) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable max-params */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an action for when the signaling connection could not be created.
|
* Create an action for when the signaling connection could not be created.
|
||||||
*
|
*
|
||||||
* @param {JitsiConnection} connection - The JitsiConnection which failed.
|
* @param {JitsiConnection} connection - The JitsiConnection which failed.
|
||||||
* @param {string} error - Error.
|
* @param {ConnectionFailedError} error - Error.
|
||||||
* @param {string} [message] - Error message.
|
|
||||||
* @param {Object} [credentials] - The invalid credentials that failed
|
|
||||||
* the authentication.
|
|
||||||
* @param {Object} [details] - The details about the connection failed event.
|
|
||||||
* @param {boolean} [recoverable] - Indicates whether this event is recoverable
|
|
||||||
* or not.
|
|
||||||
* @public
|
* @public
|
||||||
* @returns {{
|
* @returns {{
|
||||||
* type: CONNECTION_FAILED,
|
* type: CONNECTION_FAILED,
|
||||||
* connection: JitsiConnection,
|
* connection: JitsiConnection,
|
||||||
* error: Object
|
* error: ConnectionFailedError
|
||||||
* }}
|
* }}
|
||||||
*/
|
*/
|
||||||
export function connectionFailed(
|
export function connectionFailed(
|
||||||
connection: Object,
|
connection: Object,
|
||||||
error: string,
|
error: ConnectionFailedError) {
|
||||||
message: ?string,
|
const { credentials } = error;
|
||||||
credentials: ?Object,
|
|
||||||
details: ?Object,
|
if (credentials && !Object.keys(credentials).length) {
|
||||||
recoverable: ?boolean) {
|
error.credentials = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: CONNECTION_FAILED,
|
type: CONNECTION_FAILED,
|
||||||
connection,
|
connection,
|
||||||
|
error
|
||||||
// Make the error resemble an Error instance (to the extent that
|
|
||||||
// jitsi-meet needs it).
|
|
||||||
error: {
|
|
||||||
credentials:
|
|
||||||
credentials && Object.keys(credentials).length
|
|
||||||
? credentials
|
|
||||||
: undefined,
|
|
||||||
message,
|
|
||||||
name: error,
|
|
||||||
details,
|
|
||||||
recoverable
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-enable max-params */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs options to be passed to the constructor of {@code JitsiConnection}
|
* Constructs options to be passed to the constructor of {@code JitsiConnection}
|
||||||
* based on the redux state.
|
* based on the redux state.
|
||||||
|
|
|
@ -13,6 +13,8 @@ import {
|
||||||
SET_LOCATION_URL
|
SET_LOCATION_URL
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
|
|
||||||
|
import type { ConnectionFailedError } from './actions.native';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reduces the Redux actions of the feature base/connection.
|
* Reduces the Redux actions of the feature base/connection.
|
||||||
*/
|
*/
|
||||||
|
@ -100,7 +102,7 @@ function _connectionFailed(
|
||||||
state: Object,
|
state: Object,
|
||||||
{ connection, error }: {
|
{ connection, error }: {
|
||||||
connection: Object,
|
connection: Object,
|
||||||
error: Object | string
|
error: ConnectionFailedError
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
// The current (similar to getCurrentConference in
|
// The current (similar to getCurrentConference in
|
||||||
|
|
Loading…
Reference in New Issue