ref(base/connection): conferenceFailed error argument

Introduce ConnectionFailedError type.
pull/2913/head jitsi-meet_3018
paweldomas 7 years ago committed by Saúl Ibarra Corretgé
parent 36ecc99b5b
commit a9ee5944e1
  1. 7
      connection.js
  2. 7
      react/features/authentication/actions.js
  3. 99
      react/features/base/connection/actions.native.js
  4. 4
      react/features/base/connection/reducer.js

@ -102,7 +102,12 @@ function connect(id, password, roomName) {
/* eslint-enable max-params */
APP.store.dispatch(
connectionFailed(
connection, error, message, credentials, details));
connection, {
credentials,
details,
message,
name: error
}));
if (isFatalJitsiConnectionError(error)) {
connection.removeEventListener(

@ -4,6 +4,7 @@ import { appNavigate } from '../app';
import { checkIfCanJoin, conferenceLeft } from '../base/conference';
import { connectionFailed } from '../base/connection';
import { openDialog } from '../base/dialog';
import { set } from '../base/redux';
import {
CANCEL_LOGIN,
@ -89,11 +90,7 @@ export function cancelLogin() {
&& dispatch(
connectionFailed(
passwordRequired,
error && error.name,
error && error.message,
error && error.credentials,
error && error.details,
/* recoverable */ false));
set(error, 'recoverable', false)));
};
}

@ -15,6 +15,53 @@ import {
SET_LOCATION_URL
} 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.
*
@ -89,10 +136,18 @@ export function connect(id: ?string, password: ?string) {
* @private
* @returns {void}
*/
function _onConnectionFailed(err, msg, credentials) {
function _onConnectionFailed(
err: string, msg: string, credentials: Object) {
unsubscribe();
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.
*
* @param {JitsiConnection} connection - The JitsiConnection which failed.
* @param {string} 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.
* @param {ConnectionFailedError} error - Error.
* @public
* @returns {{
* type: CONNECTION_FAILED,
* connection: JitsiConnection,
* error: Object
* error: ConnectionFailedError
* }}
*/
export function connectionFailed(
connection: Object,
error: string,
message: ?string,
credentials: ?Object,
details: ?Object,
recoverable: ?boolean) {
error: ConnectionFailedError) {
const { credentials } = error;
if (credentials && !Object.keys(credentials).length) {
error.credentials = undefined;
}
return {
type: CONNECTION_FAILED,
connection,
// 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
}
error
};
}
/* eslint-enable max-params */
/**
* Constructs options to be passed to the constructor of {@code JitsiConnection}
* based on the redux state.

@ -13,6 +13,8 @@ import {
SET_LOCATION_URL
} from './actionTypes';
import type { ConnectionFailedError } from './actions.native';
/**
* Reduces the Redux actions of the feature base/connection.
*/
@ -100,7 +102,7 @@ function _connectionFailed(
state: Object,
{ connection, error }: {
connection: Object,
error: Object | string
error: ConnectionFailedError
}) {
// The current (similar to getCurrentConference in

Loading…
Cancel
Save