Replace console.error with logger.error

Related https://github.com/vector-im/element-web/issues/18425
This commit is contained in:
Dariusz Niemczyk 2021-10-15 16:30:53 +02:00 committed by Dariusz Niemczyk
parent 9c594a8a96
commit 5e73a212f4
124 changed files with 417 additions and 250 deletions

View file

@ -23,6 +23,8 @@ import SdkConfig from './SdkConfig';
import Modal from './Modal';
import * as sdk from './index';
import { logger } from "matrix-js-sdk/src/logger";
const hashRegex = /#\/(groups?|room|user|settings|register|login|forgot_password|home|directory)/;
const hashVarRegex = /#\/(group|room|user)\/.*$/;
@ -156,7 +158,7 @@ function getUid(): string {
}
return data;
} catch (e) {
console.error("Analytics error: ", e);
logger.error("Analytics error: ", e);
return "";
}
}
@ -299,7 +301,7 @@ export class Analytics {
redirect: "follow",
});
} catch (e) {
console.error("Analytics error: ", e);
logger.error("Analytics error: ", e);
}
}

View file

@ -28,6 +28,8 @@ import { hideToast as hideUpdateToast } from "./toasts/UpdateToast";
import { MatrixClientPeg } from "./MatrixClientPeg";
import { idbLoad, idbSave, idbDelete } from "./utils/StorageManager";
import { logger } from "matrix-js-sdk/src/logger";
export const SSO_HOMESERVER_URL_KEY = "mx_sso_hs_url";
export const SSO_ID_SERVER_URL_KEY = "mx_sso_is_url";
export const SSO_IDP_ID_KEY = "mx_sso_idp_id";
@ -320,7 +322,7 @@ export default abstract class BasePlatform {
return null;
}
if (!data.encrypted || !data.iv || !data.cryptoKey) {
console.error("Badly formatted pickle key");
logger.error("Badly formatted pickle key");
return null;
}
@ -340,7 +342,7 @@ export default abstract class BasePlatform {
);
return encodeUnpaddedBase64(key);
} catch (e) {
console.error("Error decrypting pickle key");
logger.error("Error decrypting pickle key");
return null;
}
}

View file

@ -444,7 +444,7 @@ export default class CallHandler extends EventEmitter {
if (!this.matchesCallForThisRoom(call)) return;
Analytics.trackEvent('voip', 'callError', 'error', err.toString());
console.error("Call error:", err);
logger.error("Call error:", err);
if (err.code === CallErrorCode.NoUserMedia) {
this.showMediaCaptureError(call);
@ -777,7 +777,7 @@ export default class CallHandler extends EventEmitter {
} else if (type === 'video') {
call.placeVideoCall();
} else {
console.error("Unknown conf call type: " + type);
logger.error("Unknown conf call type: " + type);
}
}
@ -811,7 +811,7 @@ export default class CallHandler extends EventEmitter {
const room = MatrixClientPeg.get().getRoom(payload.room_id);
if (!room) {
console.error(`Room ${payload.room_id} does not exist.`);
logger.error(`Room ${payload.room_id} does not exist.`);
return;
}
@ -1112,7 +1112,7 @@ export default class CallHandler extends EventEmitter {
description: _t("You do not have permission to start a conference call in this room"),
});
}
console.error(e);
logger.error(e);
});
}

View file

@ -559,7 +559,7 @@ export default class ContentMessages {
Object.assign(content.info, imageInfo);
resolve();
}, (e) => {
console.error(e);
logger.error(e);
content.msgtype = 'm.file';
resolve();
});

View file

@ -25,6 +25,8 @@ import { MatrixClientPeg } from "./MatrixClientPeg";
import RoomViewStore from "./stores/RoomViewStore";
import { Action } from "./dispatcher/actions";
import { logger } from "matrix-js-sdk/src/logger";
const INACTIVITY_TIME = 20; // seconds
const HEARTBEAT_INTERVAL = 5_000; // ms
const SESSION_UPDATE_INTERVAL = 60; // seconds
@ -651,7 +653,7 @@ export default class CountlyAnalytics {
body: params,
});
} catch (e) {
console.error("Analytics error: ", e);
logger.error("Analytics error: ", e);
}
}

View file

@ -234,8 +234,8 @@ export function attemptTokenLogin(
}
},
});
console.error("Failed to log in with login token:");
console.error(err);
logger.error("Failed to log in with login token:");
logger.error(err);
return false;
});
}
@ -297,7 +297,7 @@ function registerAsGuest(
guest: true,
}, true).then(() => true);
}, (err) => {
console.error("Failed to register as guest", err);
logger.error("Failed to register as guest", err);
return false;
});
}
@ -452,7 +452,7 @@ export async function restoreFromLocalStorage(opts?: { ignoreGuest?: boolean }):
}
async function handleLoadSessionFailure(e: Error): Promise<boolean> {
console.error("Unable to load session", e);
logger.error("Unable to load session", e);
const modal = Modal.createTrackedDialog('Session Restore Error', '', SessionRestoreErrorDialog, {
error: e.message,
@ -676,7 +676,7 @@ async function persistCredentials(credentials: IMatrixClientCreds): Promise<void
localStorage.setItem("mx_access_token", credentials.accessToken);
}
if (localStorage.getItem("mx_has_pickle_key")) {
console.error("Expected a pickle key, but none provided. Encryption may not work.");
logger.error("Expected a pickle key, but none provided. Encryption may not work.");
}
}

View file

@ -173,12 +173,12 @@ class MatrixClientPegClass implements IMatrixClientPeg {
break;
} catch (err) {
if (dbType === 'indexeddb') {
console.error('Error starting matrixclient store - falling back to memory store', err);
logger.error('Error starting matrixclient store - falling back to memory store', err);
this.matrixClient.store = new MemoryStore({
localStorage: localStorage,
});
} else {
console.error('Failed to start memory store!', err);
logger.error('Failed to start memory store!', err);
throw err;
}
}

View file

@ -170,7 +170,7 @@ export const Notifier = {
let audioElement = selector;
if (!selector) {
if (!sound) {
console.error("No audio element or sound to play for notification");
logger.error("No audio element or sound to play for notification");
return;
}
audioElement = new Audio(sound.url);

View file

@ -21,6 +21,8 @@ import dis from "./dispatcher/dispatcher";
import Timer from './utils/Timer';
import { ActionPayload } from "./dispatcher/payloads";
import { logger } from "matrix-js-sdk/src/logger";
// Time in ms after that a user is considered as unavailable/away
const UNAVAILABLE_TIME_MS = 3 * 60 * 1000; // 3 mins
@ -101,7 +103,7 @@ class Presence {
await MatrixClientPeg.get().setPresence({ presence: this.state });
console.info("Presence:", newState);
} catch (err) {
console.error("Failed to set presence:", err);
logger.error("Failed to set presence:", err);
this.state = oldState;
}
}

View file

@ -30,6 +30,8 @@ import BaseAvatar from "./components/views/avatars/BaseAvatar";
import { mediaFromMxc } from "./customisations/Media";
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
import { logger } from "matrix-js-sdk/src/logger";
export interface IInviteResult {
states: CompletionStates;
inviter: MultiInviter;
@ -114,7 +116,7 @@ export function inviteUsersToRoom(roomId: string, userIds: string[], progressCal
const room = MatrixClientPeg.get().getRoom(roomId);
showAnyInviteErrors(result.states, room, result.inviter);
}).catch((err) => {
console.error(err.stack);
logger.error(err.stack);
Modal.createTrackedDialog('Failed to invite', '', ErrorDialog, {
title: _t("Failed to invite"),
description: ((err && err.message) ? err.message : _t("Operation failed")),

View file

@ -272,7 +272,7 @@ function sendResponse(event: MessageEvent<any>, res: any): void {
}
function sendError(event: MessageEvent<any>, msg: string, nestedError?: Error): void {
console.error("Action:" + event.data.action + " failed with message: " + msg);
logger.error("Action:" + event.data.action + " failed with message: " + msg);
const data = objectClone(event.data);
data.response = {
error: {
@ -721,7 +721,7 @@ export function stopListening(): void {
"ScalarMessaging: mismatched startListening / stopListening detected." +
" Negative count",
);
console.error(e);
logger.error(e);
}
}

View file

@ -399,7 +399,7 @@ export async function accessSecretStorage(func = async () => { }, forceReset = f
return await func();
} catch (e) {
SecurityCustomisations.catchAccessSecretStorageError?.(e);
console.error(e);
logger.error(e);
// Re-throw so that higher level logic can abort as needed
throw e;
} finally {

View file

@ -27,6 +27,8 @@ import { SortAlgorithm } from "../stores/room-list/algorithms/models";
import { DefaultTagID } from "../stores/room-list/models";
import ErrorDialog from '../components/views/dialogs/ErrorDialog';
import { logger } from "matrix-js-sdk/src/logger";
export default class RoomListActions {
/**
* Creates an action thunk that will do an asynchronous request to
@ -88,7 +90,7 @@ export default class RoomListActions {
return Rooms.guessAndSetDMRoom(
room, newTag === DefaultTagID.DM,
).catch((err) => {
console.error("Failed to set direct chat tag " + err);
logger.error("Failed to set direct chat tag " + err);
Modal.createTrackedDialog('Failed to set direct chat tag', '', ErrorDialog, {
title: _t('Failed to set direct chat tag'),
description: ((err && err.message) ? err.message : _t('Operation failed')),
@ -108,7 +110,7 @@ export default class RoomListActions {
const promiseToDelete = matrixClient.deleteRoomTag(
roomId, oldTag,
).catch(function(err) {
console.error("Failed to remove tag " + oldTag + " from room: " + err);
logger.error("Failed to remove tag " + oldTag + " from room: " + err);
Modal.createTrackedDialog('Failed to remove tag from room', '', ErrorDialog, {
title: _t('Failed to remove tag %(tagName)s from room', { tagName: oldTag }),
description: ((err && err.message) ? err.message : _t('Operation failed')),
@ -127,7 +129,7 @@ export default class RoomListActions {
metaData = metaData || {};
const promiseToAdd = matrixClient.setRoomTag(roomId, newTag, metaData).catch(function(err) {
console.error("Failed to add tag " + newTag + " to room: " + err);
logger.error("Failed to add tag " + newTag + " to room: " + err);
Modal.createTrackedDialog('Failed to add tag to room', '', ErrorDialog, {
title: _t('Failed to add tag %(tagName)s to room', { tagName: newTag }),
description: ((err && err.message) ? err.message : _t('Operation failed')),

View file

@ -26,6 +26,8 @@ import AccessibleButton from "../../../../components/views/elements/AccessibleBu
import { copyNode } from "../../../../utils/strings";
import PassphraseField from "../../../../components/views/auth/PassphraseField";
import { logger } from "matrix-js-sdk/src/logger";
const PHASE_PASSPHRASE = 0;
const PHASE_PASSPHRASE_CONFIRM = 1;
const PHASE_SHOWKEY = 2;
@ -129,7 +131,7 @@ export default class CreateKeyBackupDialog extends React.PureComponent {
phase: PHASE_DONE,
});
} catch (e) {
console.error("Error creating key backup", e);
logger.error("Error creating key backup", e);
// TODO: If creating a version succeeds, but backup fails, should we
// delete the version, disable backup, or do nothing? If we just
// disable without deleting, we'll enable on next app reload since

View file

@ -349,7 +349,7 @@ export default class CreateSecretStorageDialog extends React.PureComponent {
} else {
this.setState({ error: e });
}
console.error("Error bootstrapping secret storage", e);
logger.error("Error bootstrapping secret storage", e);
}
}

View file

@ -23,6 +23,8 @@ import { MatrixClient } from 'matrix-js-sdk/src/client';
import * as MegolmExportEncryption from '../../../../utils/MegolmExportEncryption';
import * as sdk from '../../../../index';
import { logger } from "matrix-js-sdk/src/logger";
const PHASE_EDIT = 1;
const PHASE_EXPORTING = 2;
@ -83,7 +85,7 @@ export default class ExportE2eKeysDialog extends React.Component {
FileSaver.saveAs(blob, 'element-keys.txt');
this.props.onFinished(true);
}).catch((e) => {
console.error("Error exporting e2e keys:", e);
logger.error("Error exporting e2e keys:", e);
if (this._unmounted) {
return;
}

View file

@ -22,6 +22,8 @@ import * as MegolmExportEncryption from '../../../../utils/MegolmExportEncryptio
import * as sdk from '../../../../index';
import { _t } from '../../../../languageHandler';
import { logger } from "matrix-js-sdk/src/logger";
function readFileAsArrayBuffer(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
@ -91,7 +93,7 @@ export default class ImportE2eKeysDialog extends React.Component {
// TODO: it would probably be nice to give some feedback about what we've imported here.
this.props.onFinished(true);
}).catch((e) => {
console.error("Error importing e2e keys:", e);
logger.error("Error importing e2e keys:", e);
if (this._unmounted) {
return;
}

View file

@ -156,18 +156,18 @@ export class Playback extends EventEmitter implements IDestroyable {
try {
// This error handler is largely for Safari as well, which doesn't support Opus/Ogg
// very well.
console.error("Error decoding recording: ", e);
logger.error("Error decoding recording: ", e);
console.warn("Trying to re-encode to WAV instead...");
const wav = await decodeOgg(this.buf);
// noinspection ES6MissingAwait - not needed when using callbacks
this.context.decodeAudioData(wav, b => resolve(b), e => {
console.error("Still failed to decode recording: ", e);
logger.error("Still failed to decode recording: ", e);
reject(e);
});
} catch (e) {
console.error("Caught decoding error:", e);
logger.error("Caught decoding error:", e);
reject(e);
}
});

View file

@ -32,6 +32,8 @@ import { FixedRollingArray } from "../utils/FixedRollingArray";
import { clamp } from "../utils/numbers";
import mxRecorderWorkletPath from "./RecorderWorklet";
import { logger } from "matrix-js-sdk/src/logger";
const CHANNELS = 1; // stereo isn't important
export const SAMPLE_RATE = 48000; // 48khz is what WebRTC uses. 12khz is where we lose quality.
const BITRATE = 24000; // 24kbps is pretty high quality for our use case in opus.
@ -171,9 +173,9 @@ export class VoiceRecording extends EventEmitter implements IDestroyable {
this.buffer = newBuf;
};
} catch (e) {
console.error("Error starting recording: ", e);
logger.error("Error starting recording: ", e);
if (e instanceof DOMException) { // Unhelpful DOMExceptions are common - parse them sanely
console.error(`${e.name} (${e.code}): ${e.message}`);
logger.error(`${e.name} (${e.code}): ${e.message}`);
}
// Clean up as best as possible

View file

@ -39,6 +39,8 @@ import { TileShape } from '../views/rooms/EventTile';
import { Layout } from "../../settings/Layout";
import RoomContext, { TimelineRenderingType } from '../../contexts/RoomContext';
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
roomId: string;
onClose: () => void;
@ -210,10 +212,10 @@ class FilePanel extends React.Component<IProps, IState> {
this.setState({ timelineSet: timelineSet });
} catch (error) {
console.error("Failed to get or create file panel filter", error);
logger.error("Failed to get or create file panel filter", error);
}
} else {
console.error("Failed to add filtered timelineSet for FilePanel as no room!");
logger.error("Failed to add filtered timelineSet for FilePanel as no room!");
}
}

View file

@ -45,6 +45,8 @@ import { createSpaceFromCommunity } from "../../utils/space";
import { Action } from "../../dispatcher/actions";
import { RightPanelPhases } from "../../stores/RightPanelStorePhases";
import { logger } from "matrix-js-sdk/src/logger";
const LONG_DESC_PLACEHOLDER = _td(
`<h1>HTML for your community's page</h1>
<p>
@ -186,7 +188,7 @@ class FeaturedRoom extends React.Component {
this.props.groupId,
this.props.summaryInfo.room_id,
).catch((err) => {
console.error('Error whilst removing room from group summary', err);
logger.error('Error whilst removing room from group summary', err);
const roomName = this.props.summaryInfo.name ||
this.props.summaryInfo.canonical_alias ||
this.props.summaryInfo.room_id;
@ -352,7 +354,7 @@ class FeaturedUser extends React.Component {
this.props.groupId,
this.props.summaryInfo.user_id,
).catch((err) => {
console.error('Error whilst removing user from group summary', err);
logger.error('Error whilst removing user from group summary', err);
const displayName = this.props.summaryInfo.displayname || this.props.summaryInfo.user_id;
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog(
@ -551,7 +553,7 @@ export default class GroupView extends React.Component {
},
});
}).catch((e) => {
console.error('Error getting group inviter profile', e);
logger.error('Error getting group inviter profile', e);
}).finally(() => {
if (this._unmounted) return;
this.setState({
@ -641,7 +643,7 @@ export default class GroupView extends React.Component {
}).catch((e) => {
this.setState({ uploadingAvatar: false });
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
console.error("Failed to upload avatar image", e);
logger.error("Failed to upload avatar image", e);
Modal.createTrackedDialog('Failed to upload image', '', ErrorDialog, {
title: _t('Error'),
description: _t('Failed to upload image'),
@ -675,7 +677,7 @@ export default class GroupView extends React.Component {
saving: false,
});
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
console.error("Failed to save community profile", e);
logger.error("Failed to save community profile", e);
Modal.createTrackedDialog('Failed to update group', '', ErrorDialog, {
title: _t('Error'),
description: _t('Failed to update community'),
@ -1421,7 +1423,7 @@ export default class GroupView extends React.Component {
);
}
} else {
console.error("Invalid state for GroupView");
logger.error("Invalid state for GroupView");
return <div />;
}
}

View file

@ -29,6 +29,8 @@ import getEntryComponentForLoginType, { IStageComponent } from '../views/auth/In
import Spinner from "../views/elements/Spinner";
import { replaceableComponent } from "../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
export const ERROR_USER_CANCELLED = new Error("User cancelled auth session");
interface IProps {
@ -137,7 +139,7 @@ export default class InteractiveAuthComponent extends React.Component<IProps, IS
this.props.onAuthFinished(true, result, extra);
}).catch((error) => {
this.props.onAuthFinished(false, error);
console.error("Error during user-interactive auth:", error);
logger.error("Error during user-interactive auth:", error);
if (this.unmounted) {
return;
}

View file

@ -1580,7 +1580,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
newVersionInfo = await MatrixClientPeg.get().getKeyBackupVersion();
if (newVersionInfo !== null) haveNewVersion = true;
} catch (e) {
console.error("Saw key backup error but failed to check backup version!", e);
logger.error("Saw key backup error but failed to check backup version!", e);
return;
}
}
@ -2121,7 +2121,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
/>
);
} else {
console.error(`Unknown view ${this.state.view}`);
logger.error(`Unknown view ${this.state.view}`);
}
return <ErrorBoundary>

View file

@ -26,6 +26,8 @@ import { TileShape } from "../views/rooms/EventTile";
import { Layout } from "../../settings/Layout";
import RoomContext, { TimelineRenderingType } from "../../contexts/RoomContext";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
onClose(): void;
}
@ -59,7 +61,7 @@ export default class NotificationPanel extends React.PureComponent<IProps> {
/>
);
} else {
console.error("No notifTimelineSet available!");
logger.error("No notifTimelineSet available!");
content = <Spinner />;
}

View file

@ -48,6 +48,8 @@ import Spinner from "../views/elements/Spinner";
import { ActionPayload } from "../../dispatcher/payloads";
import { getDisplayAliasForAliasSet } from "../../Rooms";
import { logger } from "matrix-js-sdk/src/logger";
const MAX_NAME_LENGTH = 80;
const MAX_TOPIC_LENGTH = 800;
@ -285,7 +287,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
return false;
}
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
logger.error("Failed to get publicRooms: %s", JSON.stringify(err));
track('Failed to get public room list');
const brand = SdkConfig.get().brand;
this.setState({
@ -335,7 +337,7 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
}, (err) => {
modal.close();
this.refreshRoomList();
console.error("Failed to " + step + ": " + err);
logger.error("Failed to " + step + ": " + err);
Modal.createTrackedDialog('Remove from Directory Error', '', ErrorDialog, {
title: _t('Error'),
description: (err && err.message)

View file

@ -963,8 +963,8 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
} catch (err) {
const errorMessage = `Fetching room members for ${room.roomId} failed.` +
" Room members will appear incomplete.";
console.error(errorMessage);
console.error(err);
logger.error(errorMessage);
logger.error(err);
}
}
}
@ -1315,7 +1315,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
return searchPromise.then((results) => {
debuglog("search complete");
if (this.unmounted || !this.state.searching || this.searchId != localSearchId) {
console.error("Discarding stale search results");
logger.error("Discarding stale search results");
return false;
}
@ -1341,7 +1341,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
searchResults: results,
});
}, (error) => {
console.error("Search failed", error);
logger.error("Search failed", error);
Modal.createTrackedDialog('Search failed', '', ErrorDialog, {
title: _t("Search failed"),
description: ((error && error.message) ? error.message :
@ -1472,7 +1472,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
rejecting: false,
});
}, (error) => {
console.error("Failed to reject invite: %s", error);
logger.error("Failed to reject invite: %s", error);
const msg = error.message ? error.message : JSON.stringify(error);
Modal.createTrackedDialog('Failed to reject invite', '', ErrorDialog, {
@ -1505,7 +1505,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
rejecting: false,
});
} catch (error) {
console.error("Failed to reject invite: %s", error);
logger.error("Failed to reject invite: %s", error);
const msg = error.message ? error.message : JSON.stringify(error);
Modal.createTrackedDialog('Failed to reject invite', '', ErrorDialog, {

View file

@ -408,7 +408,7 @@ export default class ScrollPanel extends React.Component<IProps> {
try {
await Promise.all(fillPromises);
} catch (err) {
console.error(err);
logger.error(err);
}
}
if (isFirstCall) {

View file

@ -536,7 +536,7 @@ const SpaceSetupFirstRooms = ({ space, title, description, onFinished }) => {
}));
onFinished(roomIds[0]);
} catch (e) {
console.error("Failed to create initial space rooms", e);
logger.error("Failed to create initial space rooms", e);
setError(_t("Failed to create initial space rooms"));
}
setBusy(false);
@ -713,7 +713,7 @@ const SpaceSetupPrivateInvite = ({ space, onFinished }) => {
onFinished();
}
} catch (err) {
console.error("Failed to invite users to space: ", err);
logger.error("Failed to invite users to space: ", err);
setError(_t("We couldn't invite those users. Please check the users you want to invite and try again."));
}
setBusy(false);

View file

@ -23,6 +23,8 @@ import { replaceableComponent } from "../../utils/replaceableComponent";
import classNames from "classnames";
import AccessibleButton from "../views/elements/AccessibleButton";
import { logger } from "matrix-js-sdk/src/logger";
/**
* Represents a tab for the TabbedView.
*/
@ -90,7 +92,7 @@ export default class TabbedView extends React.Component<IProps, IState> {
if (this.props.onChange) this.props.onChange(tab.id);
this.setState({ activeTabIndex: idx });
} else {
console.error("Could not find tab " + tab.label + " in tabs");
logger.error("Could not find tab " + tab.label + " in tabs");
}
}

View file

@ -799,11 +799,11 @@ class TimelinePanel extends React.Component<IProps, IState> {
lastReadEvent,
{},
).catch((e) => {
console.error(e);
logger.error(e);
this.lastRRSentEventId = undefined;
});
} else {
console.error(e);
logger.error(e);
}
// it failed, so allow retries next time the user is active
this.lastRRSentEventId = undefined;
@ -1121,7 +1121,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
if (this.unmounted) return;
this.setState({ timelineLoading: false });
console.error(
logger.error(
`Error loading timeline panel at ${eventId}: ${error}`,
);

View file

@ -33,6 +33,8 @@ import { PASSWORD_MIN_SCORE } from '../../views/auth/RegistrationForm';
import { IValidationResult } from "../../views/elements/Validation";
import InlineSpinner from '../../views/elements/InlineSpinner';
import { logger } from "matrix-js-sdk/src/logger";
enum Phase {
// Show the forgot password inputs
Forgot = 1,
@ -147,7 +149,7 @@ export default class ForgotPassword extends React.Component<IProps, IState> {
private onVerify = async (ev: React.MouseEvent): Promise<void> => {
ev.preventDefault();
if (!this.reset) {
console.error("onVerify called before submitPasswordReset!");
logger.error("onVerify called before submitPasswordReset!");
return;
}
if (this.state.currentHttpRequest) return;

View file

@ -309,7 +309,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
busy: false,
});
} catch (e) {
console.error("Problem parsing URL or unhandled error doing .well-known discovery:", e);
logger.error("Problem parsing URL or unhandled error doing .well-known discovery:", e);
let message = _t("Failed to perform homeserver discovery");
if (e.translatedMessage) {

View file

@ -195,7 +195,7 @@ export default class Registration extends React.Component<IProps, IState> {
const loginFlows = await this.loginLogic.getFlows();
ssoFlow = loginFlows.find(f => f.type === "m.login.sso" || f.type === "m.login.cas") as ISSOFlow;
} catch (e) {
console.error("Failed to get login flows to check for SSO support", e);
logger.error("Failed to get login flows to check for SSO support", e);
}
this.setState({
@ -370,12 +370,12 @@ export default class Registration extends React.Component<IProps, IState> {
matrixClient.setPusher(emailPusher).then(() => {
logger.log("Set email branding to " + this.props.brand);
}, (error) => {
console.error("Couldn't set email branding: " + error);
logger.error("Couldn't set email branding: " + error);
});
}
}
}, (error) => {
console.error("Couldn't get pushers: " + error);
logger.error("Couldn't get pushers: " + error);
});
}

View file

@ -173,7 +173,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
}
Lifecycle.hydrateSession(credentials).catch((e) => {
console.error(e);
logger.error(e);
this.setState({ busy: false, errorText: _t("Failed to re-authenticate") });
});
};
@ -193,7 +193,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
try {
credentials = await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
} catch (e) {
console.error(e);
logger.error(e);
this.setState({ busy: false, loginView: LOGIN_VIEW.UNSUPPORTED });
return;
}
@ -201,7 +201,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
Lifecycle.hydrateSession(credentials).then(() => {
if (this.props.onTokenLoginCompleted) this.props.onTokenLoginCompleted();
}).catch((e) => {
console.error(e);
logger.error(e);
this.setState({ busy: false, loginView: LOGIN_VIEW.UNSUPPORTED });
});
}

View file

@ -21,6 +21,8 @@ import { UPDATE_EVENT } from "../../../stores/AsyncStore";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { _t } from "../../../languageHandler";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
// Playback instance to render. Cannot change during component lifecycle: create
// an all-new component instead.
@ -50,7 +52,7 @@ export default abstract class AudioPlayerBase extends React.PureComponent<IProps
// Don't wait for the promise to complete - it will emit a progress update when it
// is done, and it's not meant to take long anyhow.
this.props.playback.prepare().catch(e => {
console.error("Error processing audio file:", e);
logger.error("Error processing audio file:", e);
this.setState({ error: true });
});
}

View file

@ -85,13 +85,13 @@ export default class CaptchaForm extends React.Component<ICaptchaFormProps, ICap
private renderRecaptcha(divId: string) {
if (!this.isRecaptchaReady()) {
console.error("grecaptcha not loaded!");
logger.error("grecaptcha not loaded!");
throw new Error("Recaptcha did not load successfully");
}
const publicKey = this.props.sitePublicKey;
if (!publicKey) {
console.error("No public key for recaptcha!");
logger.error("No public key for recaptcha!");
throw new Error(
"This server has not supplied enough information for Recaptcha "
+ "authentication");

View file

@ -32,6 +32,8 @@ import RegistrationEmailPromptDialog from '../dialogs/RegistrationEmailPromptDia
import { replaceableComponent } from "../../../utils/replaceableComponent";
import CountryDropdown from "./CountryDropdown";
import { logger } from "matrix-js-sdk/src/logger";
enum RegistrationField {
Email = "field_email",
PhoneNumber = "field_phone_number",
@ -84,7 +86,7 @@ interface IState {
@replaceableComponent("views.auth.RegistrationForm")
export default class RegistrationForm extends React.PureComponent<IProps, IState> {
static defaultProps = {
onValidationChange: console.error,
onValidationChange: logger.error,
canSubmit: true,
};

View file

@ -25,6 +25,8 @@ import BaseAvatar from "./BaseAvatar";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { mediaFromMxc } from "../../../customisations/Media";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends Omit<React.ComponentProps<typeof BaseAvatar>, "name" | "idName" | "url"> {
member: RoomMember;
fallbackUserId?: string;
@ -85,7 +87,7 @@ export default class MemberAvatar extends React.Component<IProps, IState> {
title: props.fallbackUserId,
};
} else {
console.error("MemberAvatar called somehow with null member or fallbackUserId");
logger.error("MemberAvatar called somehow with null member or fallbackUserId");
}
}

View file

@ -25,6 +25,8 @@ import GroupStore from "../../../stores/GroupStore";
import { MenuItem } from "../../structures/ContextMenu";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
@replaceableComponent("views.context_menus.GroupInviteTileContextMenu")
export default class GroupInviteTileContextMenu extends React.Component {
static propTypes = {
@ -62,7 +64,7 @@ export default class GroupInviteTileContextMenu extends React.Component {
try {
await GroupStore.leaveGroup(this.props.group.groupId);
} catch (e) {
console.error("Error rejecting community invite: ", e);
logger.error("Error rejecting community invite: ", e);
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Error rejecting invite', '', ErrorDialog, {
title: _t("Error"),

View file

@ -34,6 +34,8 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { Container, WidgetLayoutStore } from "../../../stores/widgets/WidgetLayoutStore";
import { getConfigLivestreamUrl, startJitsiAudioLivestream } from "../../../Livestream";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends React.ComponentProps<typeof IconizedContextMenu> {
app: IApp;
userWidget?: boolean;
@ -65,7 +67,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
try {
await startJitsiAudioLivestream(widgetMessaging, roomId);
} catch (err) {
console.error("Failed to start livestream", err);
logger.error("Failed to start livestream", err);
// XXX: won't i18n well, but looks like widget api only support 'message'?
const message = err.message || _t("Unable to start audio streaming.");
Modal.createTrackedDialog('WidgetContext Menu', 'Livestream failed', ErrorDialog, {
@ -114,7 +116,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
file: data.screenshot,
});
}).catch(err => {
console.error("Failed to take screenshot: ", err);
logger.error("Failed to take screenshot: ", err);
});
onFinished();
};
@ -165,7 +167,7 @@ const WidgetContextMenu: React.FC<IProps> = ({
current[app.eventId] = false;
const level = SettingsStore.firstSupportedLevel("allowedWidgets");
SettingsStore.setValue("allowedWidgets", roomId, level, current).catch(err => {
console.error(err);
logger.error(err);
// We don't really need to do anything about this - the user will just hit the button again.
});
onFinished();

View file

@ -41,6 +41,8 @@ import TruncatedList from "../elements/TruncatedList";
import EntityTile from "../rooms/EntityTile";
import BaseAvatar from "../avatars/BaseAvatar";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
space: Room;
onCreateRoomClick(): void;
@ -160,7 +162,7 @@ export const AddExistingToSpace: React.FC<IAddExistingToSpaceProps> = ({
});
setProgress(i => i + 1);
} catch (e) {
console.error("Failed to add rooms to space", e);
logger.error("Failed to add rooms to space", e);
setError(error = e);
break;
}

View file

@ -37,6 +37,8 @@ import AddressTile from '../elements/AddressTile';
import BaseDialog from "./BaseDialog";
import DialogButtons from "../elements/DialogButtons";
import { logger } from "matrix-js-sdk/src/logger";
const TRUNCATE_QUERY_LIST = 40;
const QUERY_USER_DIRECTORY_DEBOUNCE_MS = 200;
@ -225,7 +227,7 @@ export default class AddressPickerDialog extends React.Component<IProps, IState>
this.doRoomSearch(query);
}
} else {
console.error('Unknown pickerType', this.props.pickerType);
logger.error('Unknown pickerType', this.props.pickerType);
}
}, QUERY_USER_DIRECTORY_DEBOUNCE_MS);
} else {
@ -282,7 +284,7 @@ export default class AddressPickerDialog extends React.Component<IProps, IState>
});
this.processResults(results, query);
}).catch((err) => {
console.error('Error whilst searching group rooms: ', err);
logger.error('Error whilst searching group rooms: ', err);
this.setState({
searchError: err.errcode ? err.message : _t('Something went wrong!'),
});
@ -388,7 +390,7 @@ export default class AddressPickerDialog extends React.Component<IProps, IState>
}
this.processResults(resp.results, query);
}).catch((err) => {
console.error('Error whilst searching user directory: ', err);
logger.error('Error whilst searching user directory: ', err);
this.setState({
searchError: err.errcode ? err.message : _t('Something went wrong!'),
});
@ -582,7 +584,7 @@ export default class AddressPickerDialog extends React.Component<IProps, IState>
}],
});
} catch (e) {
console.error(e);
logger.error(e);
this.setState({
searchError: _t('Something went wrong!'),
});

View file

@ -33,6 +33,8 @@ import ErrorDialog from "./ErrorDialog";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { mediaFromMxc } from "../../../customisations/Media";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
roomId: string;
communityName: string;
@ -99,7 +101,7 @@ export default class CommunityPrototypeInviteDialog extends React.PureComponent<
}
} catch (e) {
this.setState({ busy: false });
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Failed to invite', '', ErrorDialog, {
title: _t("Failed to invite"),
description: ((e && e.message) ? e.message : _t("Operation failed")),

View file

@ -27,6 +27,8 @@ import { showCommunityRoomInviteDialog } from "../../../RoomInvite";
import GroupStore from "../../../stores/GroupStore";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
}
@ -110,7 +112,7 @@ export default class CreateCommunityPrototypeDialog extends React.PureComponent<
});
}
} catch (e) {
console.error(e);
logger.error(e);
this.setState({
busy: false,
error: _t(

View file

@ -42,6 +42,8 @@ import TagOrderActions from "../../../actions/TagOrderActions";
import { inviteUsersToRoom } from "../../../RoomInvite";
import ProgressBar from "../elements/ProgressBar";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
matrixClient: MatrixClient;
groupId: string;
@ -271,7 +273,7 @@ const CreateSpaceFromCommunityDialog: React.FC<IProps> = ({ matrixClient: cli, g
},
}, "mx_CreateSpaceFromCommunityDialog_SuccessInfoDialog");
} catch (e) {
console.error(e);
logger.error(e);
setError(e);
}

View file

@ -30,6 +30,8 @@ import { createSpace, SpaceCreateForm } from "../spaces/SpaceCreateMenu";
import { SubspaceSelector } from "./AddExistingToSpaceDialog";
import JoinRuleDropdown from "../elements/JoinRuleDropdown";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
space: Room;
onAddExistingSpaceClick(): void;
@ -83,7 +85,7 @@ const CreateSubspaceDialog: React.FC<IProps> = ({ space, onAddExistingSpaceClick
onFinished(true);
} catch (e) {
console.error(e);
logger.error(e);
}
};

View file

@ -28,6 +28,8 @@ import StyledCheckbox from "../elements/StyledCheckbox";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import BaseDialog from "./BaseDialog";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
onFinished: (success: boolean) => void;
}
@ -112,7 +114,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
return;
}
console.error("Error during UI Auth:", { result });
logger.error("Error during UI Auth:", { result });
this.setState({ errStr: _t("There was a problem communicating with the server. Please try again.") });
};
@ -126,7 +128,7 @@ export default class DeactivateAccountDialog extends React.Component<IProps, ISt
Lifecycle.onLoggedOut();
this.props.onFinished(true);
}).catch(e => {
console.error(e);
logger.error(e);
this.setState({ errStr: _t("There was a problem communicating with the server. Please try again.") });
});
};

View file

@ -26,6 +26,8 @@ import FlairStore from "../../../stores/FlairStore";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { mediaFromMxc } from "../../../customisations/Media";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
communityId: string;
}
@ -89,7 +91,7 @@ export default class EditCommunityPrototypeDialog extends React.PureComponent<IP
// we did it, so close the dialog
this.props.onFinished(true);
} catch (e) {
console.error(e);
logger.error(e);
this.setState({
busy: false,
error: _t("There was an error updating your community. The server is unable to process your request."),

View file

@ -38,6 +38,8 @@ import Exporter from "../../../utils/exportUtils/Exporter";
import Spinner from "../elements/Spinner";
import InfoDialog from "./InfoDialog";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
room: Room;
}
@ -102,7 +104,7 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
);
break;
default:
console.error("Unknown export format");
logger.error("Unknown export format");
return;
}
};

View file

@ -731,7 +731,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
await createRoom(createRoomOptions);
this.props.onFinished();
} catch (err) {
console.error(err);
logger.error(err);
this.setState({
busy: false,
errorText: _t("We couldn't create your DM."),
@ -749,7 +749,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
const cli = MatrixClientPeg.get();
const room = cli.getRoom(this.props.roomId);
if (!room) {
console.error("Failed to find the room to invite users to");
logger.error("Failed to find the room to invite users to");
this.setState({
busy: false,
errorText: _t("Something went wrong trying to invite the users."),
@ -784,7 +784,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
}
}
} catch (err) {
console.error(err);
logger.error(err);
this.setState({
busy: false,
errorText: _t(
@ -893,8 +893,8 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
})),
});
}).catch(e => {
console.error("Error searching user directory:");
console.error(e);
logger.error("Error searching user directory:");
logger.error(e);
this.setState({ serverResultsMixin: [] }); // clear results because it's moderately fatal
});
@ -948,8 +948,8 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
}],
});
} catch (e) {
console.error("Error searching identity server:");
console.error(e);
logger.error("Error searching identity server:");
logger.error(e);
this.setState({ threepidResultsMixin: [] }); // clear results because it's moderately fatal
}
}
@ -1062,8 +1062,8 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
avatar_url: avatarUrl,
}));
} catch (e) {
console.error("Error looking up profile for " + address);
console.error(e);
logger.error("Error looking up profile for " + address);
logger.error(e);
failed.push(address);
}
}
@ -1513,7 +1513,7 @@ export default class InviteDialog extends React.PureComponent<IInviteDialogProps
</AccessibleButton>
</div>;
} else {
console.error("Unknown kind of InviteDialog: " + this.props.kind);
logger.error("Unknown kind of InviteDialog: " + this.props.kind);
}
const goButton = this.props.kind == KIND_CALL_TRANSFER ? null : <AccessibleButton

View file

@ -30,6 +30,8 @@ import { IDialogProps } from "./IDialogProps";
import { EventType, RelationType } from "matrix-js-sdk/src/@types/event";
import { defer } from "matrix-js-sdk/src/utils";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
mxEvent: MatrixEvent;
}
@ -78,7 +80,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent<IProps
} catch (error) {
// log if the server returned an error
if (error.errcode) {
console.error("fetching /relations failed with error", error);
logger.error("fetching /relations failed with error", error);
}
this.setState({ error }, () => reject(error));
return promise;

View file

@ -28,6 +28,8 @@ import TextWithTooltip from "../elements/TextWithTooltip";
import withValidation, { IFieldState } from "../elements/Validation";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
title?: string;
serverConfig: ValidatedServerConfig;
@ -93,7 +95,7 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
this.validatedConf = AutoDiscoveryUtils.buildValidatedConfigFromDiscovery(hsUrl, discoveryResult);
return {}; // we have a validated config, we don't need to try the other paths
} catch (e) {
console.error(`Attempted ${hsUrl} as a server_name but it failed`, e);
logger.error(`Attempted ${hsUrl} as a server_name but it failed`, e);
}
}
@ -107,7 +109,7 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
this.validatedConf = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl);
return {};
} catch (e) {
console.error(e);
logger.error(e);
const stateForError = AutoDiscoveryUtils.authComponentStateForError(e);
if (stateForError.serverErrorIsFatal) {
@ -123,7 +125,7 @@ export default class ServerPickerDialog extends React.PureComponent<IProps, ISta
this.validatedConf = await AutoDiscoveryUtils.validateServerConfigWithStaticUrls(hsUrl, null, true);
return {};
} catch (e) {
console.error(e);
logger.error(e);
return { error: _t("Invalid URL") };
}
}

View file

@ -28,6 +28,8 @@ import BaseDialog from "./BaseDialog";
import EditableText from "../elements/EditableText";
import { IDialogProps } from "./IDialogProps";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
title: string;
}
@ -83,7 +85,7 @@ export default class SetEmailDialog extends React.Component<IProps, IState> {
});
}, (err) => {
this.setState({ emailBusy: false });
console.error("Unable to add email address " + emailAddress + " " + err);
logger.error("Unable to add email address " + emailAddress + " " + err);
Modal.createTrackedDialog('Unable to add email address', '', ErrorDialog, {
title: _t("Unable to add email address"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
@ -119,7 +121,7 @@ export default class SetEmailDialog extends React.Component<IProps, IState> {
onFinished: this.onEmailDialogFinished,
});
} else {
console.error("Unable to verify email address: " + err);
logger.error("Unable to verify email address: " + err);
Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, {
title: _t("Unable to verify email address."),
description: ((err && err.message) ? err.message : _t("Operation failed")),

View file

@ -27,6 +27,8 @@ import AccessibleButton from "../elements/AccessibleButton";
import IntegrationManager from "../settings/IntegrationManager";
import { IDialogProps } from "./IDialogProps";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
/**
* Optional room where the integration manager should be open to
@ -116,7 +118,7 @@ export default class TabbedIntegrationManagerDialog extends React.Component<IPro
return;
}
console.error(e);
logger.error(e);
this.setState({
busy: false,
currentLoading: false,

View file

@ -28,6 +28,8 @@ import { IDialogProps } from "../IDialogProps";
import { accessSecretStorage } from "../../../../SecurityManager";
import Modal from "../../../../Modal";
import { logger } from "matrix-js-sdk/src/logger";
// Maximum acceptable size of a key file. It's 59 characters including the spaces we encode,
// so this should be plenty and allow for people putting extra whitespace in the file because
// maybe that's a thing people would do?
@ -252,7 +254,7 @@ export default class AccessSecretStorageDialog extends React.PureComponent<IProp
this.props.onFinished(true);
}, true);
} catch (e) {
console.error(e);
logger.error(e);
this.props.onFinished(false);
}
};

View file

@ -165,7 +165,7 @@ export default class CreateCrossSigningDialog extends React.PureComponent<IProps
}
this.setState({ error: e });
console.error("Error bootstrapping cross-signing", e);
logger.error("Error bootstrapping cross-signing", e);
}
};

View file

@ -324,7 +324,7 @@ export default class AppTile extends React.Component<IProps, IState> {
// Fetch a token for the integration manager, now that we're allowed to
this.startWidget();
}).catch(err => {
console.error(err);
logger.error(err);
// We don't really need to do anything about this - the user will just hit the button again.
});
};

View file

@ -25,6 +25,8 @@ import { replaceableComponent } from "../../../utils/replaceableComponent";
import BugReportDialog from '../dialogs/BugReportDialog';
import AccessibleButton from './AccessibleButton';
import { logger } from "matrix-js-sdk/src/logger";
interface IState {
error: Error;
}
@ -52,8 +54,8 @@ export default class ErrorBoundary extends React.PureComponent<{}, IState> {
componentDidCatch(error: Error, { componentStack }: ErrorInfo): void {
// Browser consoles are better at formatting output when native errors are passed
// in their own `console.error` invocation.
console.error(error);
console.error(
logger.error(error);
logger.error(
"The above error occured while React was rendering the following components:",
componentStack,
);

View file

@ -22,6 +22,8 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { mediaFromMxc } from "../../../customisations/Media";
import { logger } from "matrix-js-sdk/src/logger";
class FlairAvatar extends React.Component {
constructor() {
super();
@ -92,7 +94,7 @@ export default class Flair extends React.Component {
try {
groupProfile = await FlairStore.getGroupProfileCached(this.context, groupId);
} catch (err) {
console.error('Could not get profile for group', groupId, err);
logger.error('Could not get profile for group', groupId, err);
}
profiles.push(groupProfile);
}

View file

@ -29,6 +29,8 @@ import { mediaFromMxc } from "../../../customisations/Media";
import Tooltip from './Tooltip';
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
@replaceableComponent("views.elements.Pill")
class Pill extends React.Component {
static roomNotifPos(text) {
@ -188,7 +190,7 @@ class Pill extends React.Component {
};
this.setState({ member });
}).catch((err) => {
console.error('Could not retrieve profile data for ' + userId + ':', err);
logger.error('Could not retrieve profile data for ' + userId + ':', err);
});
}

View file

@ -27,6 +27,8 @@ import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { mediaFromMxc } from "../../../customisations/Media";
import { logger } from "matrix-js-sdk/src/logger";
@replaceableComponent("views.groups.GroupRoomInfo")
export default class GroupRoomInfo extends React.Component {
static contextType = MatrixClientContext;
@ -103,7 +105,7 @@ export default class GroupRoomInfo extends React.Component {
action: "view_group_room_list",
});
}).catch((err) => {
console.error(`Error whilst removing ${roomId} from ${groupId}`, err);
logger.error(`Error whilst removing ${roomId} from ${groupId}`, err);
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Failed to remove room from group', '', ErrorDialog, {
title: _t("Failed to remove room from community"),
@ -133,7 +135,7 @@ export default class GroupRoomInfo extends React.Component {
const roomId = this.props.groupRoomId;
const roomName = this.state.groupRoom.displayname;
GroupStore.updateGroupRoomVisibility(this.props.groupId, roomId, isPublic).catch((err) => {
console.error(`Error whilst changing visibility of ${roomId} in ${groupId} to ${isPublic}`, err);
logger.error(`Error whilst changing visibility of ${roomId} in ${groupId} to ${isPublic}`, err);
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Failed to remove room from group', '', ErrorDialog, {
title: _t("Something went wrong!"),

View file

@ -26,6 +26,8 @@ import { _t } from "../../../languageHandler";
import TagOrderActions from "../../../actions/TagOrderActions";
import GroupFilterOrderStore from "../../../stores/GroupFilterOrderStore";
import { logger } from "matrix-js-sdk/src/logger";
@replaceableComponent("views.groups.GroupTile")
class GroupTile extends React.Component {
static propTypes = {
@ -51,7 +53,7 @@ class GroupTile extends React.Component {
FlairStore.getGroupProfileCached(this.context, this.props.groupId).then((profile) => {
this.setState({ profile });
}).catch((err) => {
console.error('Error whilst getting cached profile for GroupTile', err);
logger.error('Error whilst getting cached profile for GroupTile', err);
});
}

View file

@ -20,6 +20,8 @@ import { _t } from '../../../languageHandler';
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
@replaceableComponent("views.groups.GroupUserSettings")
export default class GroupUserSettings extends React.Component {
static contextType = MatrixClientContext;
@ -33,7 +35,7 @@ export default class GroupUserSettings extends React.Component {
this.context.getJoinedGroups().then((result) => {
this.setState({ groups: result.groups || [], error: null });
}, (err) => {
console.error(err);
logger.error(err);
this.setState({ groups: null, error: err });
});
}

View file

@ -27,6 +27,8 @@ import EventTileBubble from "./EventTileBubble";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import AccessibleButton from '../elements/AccessibleButton';
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
mxEvent: MatrixEvent;
}
@ -68,7 +70,7 @@ export default class MKeyVerificationRequest extends React.Component<IProps> {
this.openRequest();
await request.accept();
} catch (err) {
console.error(err.message);
logger.error(err.message);
}
}
};
@ -79,7 +81,7 @@ export default class MKeyVerificationRequest extends React.Component<IProps> {
try {
await request.cancel();
} catch (err) {
console.error(err.message);
logger.error(err.message);
}
}
};

View file

@ -29,6 +29,8 @@ import { useAsyncMemo } from "../../../hooks/useAsyncMemo";
import PinnedEventTile from "../rooms/PinnedEventTile";
import { useRoomState } from "../../../hooks/useRoomState";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
room: Room;
onClose(): void;
@ -107,8 +109,8 @@ const PinnedMessagesCard = ({ room, onClose }: IProps) => {
return event;
}
} catch (err) {
console.error("Error looking up pinned event " + eventId + " in room " + room.roomId);
console.error(err);
logger.error("Error looking up pinned event " + eventId + " in room " + room.roomId);
logger.error(err);
}
return null;
});

View file

@ -582,7 +582,7 @@ const RoomKickButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBas
// get out of sync if we force setState here!
logger.log("Kick success");
}, function(err) {
console.error("Kick error: " + err);
logger.error("Kick error: " + err);
Modal.createTrackedDialog('Failed to kick', '', ErrorDialog, {
title: _t("Failed to kick"),
description: ((err && err.message) ? err.message : "Operation failed"),
@ -664,8 +664,8 @@ const RedactMessagesButton: React.FC<IBaseProps> = ({ member }) => {
await cli.redactEvent(roomId, event.getId());
} catch (err) {
// log and swallow errors
console.error("Could not redact", event.getId());
console.error(err);
logger.error("Could not redact", event.getId());
logger.error(err);
}
}));
console.info(`Finished redacting recent ${count} messages for ${user} in ${roomId}`);
@ -744,7 +744,7 @@ const BanToggleButton = ({ room, member, startUpdating, stopUpdating }: Omit<IBa
// get out of sync if we force setState here!
logger.log("Ban success");
}, function(err) {
console.error("Ban error: " + err);
logger.error("Ban error: " + err);
Modal.createTrackedDialog('Failed to ban user', '', ErrorDialog, {
title: _t("Error"),
description: _t("Failed to ban user"),
@ -789,7 +789,7 @@ const MuteToggleButton: React.FC<IBaseRoomProps> = ({ member, room, powerLevels,
try {
if (!(await warnSelfDemote(SpaceStore.spacesEnabled && room?.isSpaceRoom()))) return;
} catch (e) {
console.error("Failed to warn about self demotion: ", e);
logger.error("Failed to warn about self demotion: ", e);
return;
}
}
@ -817,7 +817,7 @@ const MuteToggleButton: React.FC<IBaseRoomProps> = ({ member, room, powerLevels,
// get out of sync if we force setState here!
logger.log("Mute toggle success");
}, function(err) {
console.error("Mute error: " + err);
logger.error("Mute error: " + err);
Modal.createTrackedDialog('Failed to mute user', '', ErrorDialog, {
title: _t("Error"),
description: _t("Failed to mute user"),
@ -1130,7 +1130,7 @@ const PowerLevelEditor: React.FC<{
// get out of sync if we force setState here!
logger.log("Power change success");
}, function(err) {
console.error("Failed to change power level " + err);
logger.error("Failed to change power level " + err);
Modal.createTrackedDialog('Failed to change power level', '', ErrorDialog, {
title: _t("Error"),
description: _t("Failed to change power level"),
@ -1166,7 +1166,7 @@ const PowerLevelEditor: React.FC<{
try {
if (!(await warnSelfDemote(SpaceStore.spacesEnabled && room?.isSpaceRoom()))) return;
} catch (e) {
console.error("Failed to warn about self demotion: ", e);
logger.error("Failed to warn about self demotion: ", e);
}
}
@ -1315,8 +1315,8 @@ const BasicUserInfo: React.FC<{
try {
await cli.deactivateSynapseUser(member.userId);
} catch (err) {
console.error("Failed to deactivate user");
console.error(err);
logger.error("Failed to deactivate user");
logger.error(err);
Modal.createTrackedDialog('Failed to deactivate Synapse user', '', ErrorDialog, {
title: _t('Failed to deactivate user'),

View file

@ -35,6 +35,8 @@ import { replaceableComponent } from "../../../utils/replaceableComponent";
import AccessibleButton from "../elements/AccessibleButton";
import VerificationShowSas from "../verification/VerificationShowSas";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
layout: string;
request: VerificationRequest;
@ -335,7 +337,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
case Phase.Cancelled:
return this.renderCancelledPhase();
}
console.error("VerificationPanel unhandled phase:", phase);
logger.error("VerificationPanel unhandled phase:", phase);
return null;
}
@ -345,7 +347,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
try {
await verifier.verify();
} catch (err) {
console.error(err);
logger.error(err);
}
};
@ -378,7 +380,7 @@ export default class VerificationPanel extends React.PureComponent<IProps, IStat
// but that's ok as verify should return the same promise.
await request.verifier.verify();
} catch (err) {
console.error("error verify", err);
logger.error("error verify", err);
}
}
};

View file

@ -29,6 +29,8 @@ import RoomPublishSetting from "./RoomPublishSetting";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import RoomAliasField from "../elements/RoomAliasField";
import { logger } from "matrix-js-sdk/src/logger";
interface IEditableAliasesListProps {
domain?: string;
}
@ -171,7 +173,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
MatrixClientPeg.get().sendStateEvent(this.props.roomId, "m.room.canonical_alias",
eventContent, "").catch((err) => {
console.error(err);
logger.error(err);
Modal.createTrackedDialog('Error updating main address', '', ErrorDialog, {
title: _t("Error updating main address"),
description: _t(
@ -204,7 +206,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
MatrixClientPeg.get().sendStateEvent(this.props.roomId, "m.room.canonical_alias",
eventContent, "").catch((err) => {
console.error(err);
logger.error(err);
Modal.createTrackedDialog('Error updating alternative addresses', '', ErrorDialog, {
title: _t("Error updating main address"),
description: _t(
@ -236,7 +238,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
this.changeCanonicalAlias(alias);
}
}).catch((err) => {
console.error(err);
logger.error(err);
Modal.createTrackedDialog('Error creating address', '', ErrorDialog, {
title: _t("Error creating address"),
description: _t(
@ -259,7 +261,7 @@ export default class AliasSettings extends React.Component<IProps, IState> {
this.changeCanonicalAlias(null);
}
}).catch((err) => {
console.error(err);
logger.error(err);
let description;
if (err.errcode === "M_FORBIDDEN") {
description = _t("You don't have permission to delete the address.");

View file

@ -24,6 +24,8 @@ import ErrorDialog from "../dialogs/ErrorDialog";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
const GROUP_ID_REGEX = /\+\S+:\S+/;
@replaceableComponent("views.room_settings.RelatedGroupSettings")
@ -53,7 +55,7 @@ export default class RelatedGroupSettings extends React.Component {
this.context.sendStateEvent(this.props.roomId, 'm.room.related_groups', {
groups: newGroupsList,
}, '').catch((err) => {
console.error(err);
logger.error(err);
Modal.createTrackedDialog('Error updating flair', '', ErrorDialog, {
title: _t("Error updating flair"),
description: _t(

View file

@ -49,6 +49,8 @@ import { ICompletion } from "../../../autocomplete/Autocompleter";
import { AutocompleteAction, getKeyBindingsManager, MessageComposerAction } from '../../../KeyBindingsManager';
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
// matches emoticons which follow the start of a line or whitespace
const REGEX_EMOTICON_WHITESPACE = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')\\s|:^$');
export const REGEX_EMOTICON = new RegExp('(?:^|\\s)(' + EMOTICON_REGEX.source + ')$');
@ -207,7 +209,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
try {
setSelection(this.editorRef.current, this.props.model, selection);
} catch (err) {
console.error(err);
logger.error(err);
}
// if caret selection is a range, take the end position
const position = selection instanceof Range ? selection.end : selection;
@ -596,7 +598,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
this.setState({ showVisualBell: true });
}
} catch (err) {
console.error(err);
logger.error(err);
}
}

View file

@ -251,7 +251,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
const parts: Part[] = serializedParts.map(p => partCreator.deserializePart(p));
return parts;
} catch (e) {
console.error("Error parsing editing state: ", e);
logger.error("Error parsing editing state: ", e);
}
}
}
@ -329,7 +329,7 @@ class EditMessageComposer extends React.Component<IEditMessageComposerProps, ISt
}
}
if (error) {
console.error("Command failure: %s", error);
logger.error("Command failure: %s", error);
// assume the error is a server error when the command is async
const isServerError = !!result.promise;
const title = isServerError ? _td("Server error") : _td("Command error");

View file

@ -25,6 +25,8 @@ import { _t } from "../../../languageHandler";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { useAsyncMemo } from "../../../hooks/useAsyncMemo";
import { logger } from "matrix-js-sdk/src/logger";
const INITIAL_NUM_PREVIEWS = 2;
interface IProps {
@ -92,7 +94,7 @@ const fetchPreviews = (cli: MatrixClient, links: string[], ts: number):
return [link, preview];
}
} catch (error) {
console.error("Failed to get URL preview: " + error);
logger.error("Failed to get URL preview: " + error);
}
})).then(a => a.filter(Boolean)) as Promise<[string, IPreviewUrlResponse][]>;
};

View file

@ -358,7 +358,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
}
}
if (error) {
console.error("Command failure: %s", error);
logger.error("Command failure: %s", error);
// assume the error is a server error when the command is async
const isServerError = !!result.promise;
const title = isServerError ? _td("Server error") : _td("Command error");
@ -549,7 +549,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
}
return parts;
} catch (e) {
console.error(e);
logger.error(e);
}
}
}

View file

@ -107,10 +107,10 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
scalarClient.disableWidgetAssets(WidgetType.STICKERPICKER, this.state.widgetId).then(() => {
logger.log('Assets disabled');
}).catch((err) => {
console.error('Failed to disable assets');
logger.error('Failed to disable assets');
});
} else {
console.error("Cannot disable assets: no scalar client");
logger.error("Cannot disable assets: no scalar client");
}
} else {
console.warn('No widget ID specified, not disabling assets');
@ -120,7 +120,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
WidgetUtils.removeStickerpickerWidgets().then(() => {
this.forceUpdate();
}).catch((e) => {
console.error('Failed to remove sticker picker widget', e);
logger.error('Failed to remove sticker picker widget', e);
});
};
@ -152,7 +152,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
}
private imError(errorMsg: string, e: Error): void {
console.error(errorMsg, e);
logger.error(errorMsg, e);
this.setState({
imError: _t(errorMsg),
});
@ -230,7 +230,7 @@ export default class Stickerpicker extends React.PureComponent<IProps, IState> {
const messaging = WidgetMessagingStore.instance.getMessagingForId(this.state.stickerpickerWidget.id);
if (messaging && visible !== this.prevSentVisibility) {
messaging.updateVisibility(visible).catch(err => {
console.error("Error updating widget visibility: ", err);
logger.error("Error updating widget visibility: ", err);
});
this.prevSentVisibility = visible;
}

View file

@ -29,6 +29,8 @@ import ErrorDialog from '../dialogs/ErrorDialog';
import AccessibleButton from '../elements/AccessibleButton';
import SpaceStore from "../../../stores/SpaceStore";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
event: MatrixEvent;
}
@ -100,7 +102,7 @@ export default class ThirdPartyMemberInfo extends React.Component<IProps, IState
onKickClick = () => {
MatrixClientPeg.get().sendStateEvent(this.state.roomId, "m.room.third_party_invite", {}, this.state.stateKey)
.catch((err) => {
console.error(err);
logger.error(err);
// Revert echo because of error
this.setState({ invited: true });

View file

@ -36,6 +36,8 @@ import { NotificationColor } from "../../../stores/notifications/NotificationCol
import InlineSpinner from "../elements/InlineSpinner";
import { PlaybackManager } from "../../../audio/PlaybackManager";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
room: Room;
}
@ -75,7 +77,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
try {
upload = await this.state.recorder.upload(this.props.room.roomId);
} catch (e) {
console.error("Error uploading voice message:", e);
logger.error("Error uploading voice message:", e);
// Flag error and move on. The recording phase will be reset by the upload function.
this.setState({ didUploadFail: true });
@ -116,7 +118,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
"org.matrix.msc3245.voice": {}, // No content, this is a rendering hint
});
} catch (e) {
console.error("Error sending voice message:", e);
logger.error("Error sending voice message:", e);
// Voice message should be in the timeline at this point, so let other things take care
// of error handling. We also shouldn't need the recording anymore, so fall through to
@ -171,7 +173,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
}
// else we probably have a device that is good enough
} catch (e) {
console.error("Error getting devices: ", e);
logger.error("Error getting devices: ", e);
accessError();
return;
}
@ -191,7 +193,7 @@ export default class VoiceRecordComposerTile extends React.PureComponent<IProps,
this.setState({ recorder, recordingPhase: RecordingState.Started });
} catch (e) {
console.error("Error starting recording: ", e);
logger.error("Error starting recording: ", e);
accessError();
// noinspection ES6MissingAwait - if this goes wrong we don't want it to affect the call stack

View file

@ -28,6 +28,8 @@ import { MatrixEvent } from 'matrix-js-sdk/src';
import SetupEncryptionDialog from '../dialogs/security/SetupEncryptionDialog';
import { accessSecretStorage } from '../../../SecurityManager';
import { logger } from "matrix-js-sdk/src/logger";
interface IState {
error?: Error;
crossSigningPublicKeysOnDevice?: boolean;
@ -147,7 +149,7 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
});
} catch (e) {
this.setState({ error: e });
console.error("Error bootstrapping cross-signing", e);
logger.error("Error bootstrapping cross-signing", e);
}
if (this.unmounted) return;
this.getUpdatedStatus();

View file

@ -28,6 +28,8 @@ import DevicesPanelEntry from "./DevicesPanelEntry";
import Spinner from "../elements/Spinner";
import AccessibleButton from "../elements/AccessibleButton";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
className?: string;
}
@ -72,7 +74,7 @@ export default class DevicesPanel extends React.Component<IProps, IState> {
// 404 probably means the HS doesn't yet support the API.
errtxt = _t("Your homeserver does not support session management.");
} else {
console.error("Error loading sessions:", error);
logger.error("Error loading sessions:", error);
errtxt = _t("Unable to load session list");
}
this.setState({ deviceLoadError: errtxt });
@ -159,7 +161,7 @@ export default class DevicesPanel extends React.Component<IProps, IState> {
},
});
}).catch((e) => {
console.error("Error deleting sessions", e);
logger.error("Error deleting sessions", e);
if (this.unmounted) { return; }
}).finally(() => {
this.setState({

View file

@ -24,6 +24,8 @@ import StyledCheckbox from '../elements/StyledCheckbox';
import { replaceableComponent } from "../../../utils/replaceableComponent";
import EditableTextContainer from "../elements/EditableTextContainer";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
device?: IMyDevice;
onDeviceToggled?: (device: IMyDevice) => void;
@ -41,7 +43,7 @@ export default class DevicesPanelEntry extends React.Component<IProps> {
return MatrixClientPeg.get().setDeviceDetails(device.device_id, {
display_name: value,
}).catch((e) => {
console.error("Error setting session display name", e);
logger.error("Error setting session display name", e);
throw new Error(_t("Failed to set display name"));
});
};

View file

@ -39,6 +39,8 @@ import TagComposer from "../elements/TagComposer";
import { objectClone } from "../../../utils/objects";
import { arrayDiff } from "../../../utils/arrays";
import { logger } from "matrix-js-sdk/src/logger";
// TODO: this "view" component still has far too much application logic in it,
// which should be factored out to other files.
@ -139,7 +141,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
phase: Phase.Ready,
});
} catch (e) {
console.error("Error setting up notifications for settings: ", e);
logger.error("Error setting up notifications for settings: ", e);
this.setState({ phase: Phase.Error });
}
}
@ -264,7 +266,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
await this.refreshFromServer();
} catch (e) {
this.setState({ phase: Phase.Error });
console.error("Error updating master push rule:", e);
logger.error("Error updating master push rule:", e);
this.showSaveError();
}
};
@ -298,7 +300,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
await this.refreshFromServer();
} catch (e) {
this.setState({ phase: Phase.Error });
console.error("Error updating email pusher:", e);
logger.error("Error updating email pusher:", e);
this.showSaveError();
}
};
@ -367,7 +369,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
await this.refreshFromServer();
} catch (e) {
this.setState({ phase: Phase.Error });
console.error("Error updating push rule:", e);
logger.error("Error updating push rule:", e);
this.showSaveError();
}
};
@ -427,7 +429,7 @@ export default class Notifications extends React.PureComponent<IProps, IState> {
await this.refreshFromServer();
} catch (e) {
this.setState({ phase: Phase.Error });
console.error("Error updating keyword push rules:", e);
logger.error("Error updating keyword push rules:", e);
this.showSaveError();
}
}

View file

@ -210,7 +210,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
try {
await accessSecretStorage(async () => { }, /* forceReset = */ true);
} catch (e) {
console.error("Error resetting secret storage", e);
logger.error("Error resetting secret storage", e);
if (this.unmounted) return;
this.setState({ error: e });
}

View file

@ -32,6 +32,8 @@ import AccessibleButton from '../elements/AccessibleButton';
import Field from '../elements/Field';
import QuestionDialog from "../dialogs/QuestionDialog";
import { logger } from "matrix-js-sdk/src/logger";
// We'll wait up to this long when checking for 3PID bindings on the IS.
const REACHABILITY_TIMEOUT = 10000; // ms
@ -206,7 +208,7 @@ export default class SetIdServer extends React.Component<IProps, IState> {
this.saveIdServer(fullUrl);
}
} catch (e) {
console.error(e);
logger.error(e);
errStr = _t("Terms of service not accepted or the identity server is invalid.");
}
}

View file

@ -23,6 +23,8 @@ import SettingsStore from "../../../settings/SettingsStore";
import { SettingLevel } from "../../../settings/SettingLevel";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
}
@ -48,8 +50,8 @@ export default class SetIntegrationManager extends React.Component<IProps, IStat
private onProvisioningToggled = (): void => {
const current = this.state.provisioningEnabled;
SettingsStore.setValue("integrationProvisioning", null, SettingLevel.ACCOUNT, !current).catch(err => {
console.error("Error changing integration manager provisioning");
console.error(err);
logger.error("Error changing integration manager provisioning");
logger.error(err);
this.setState({ provisioningEnabled: current });
});

View file

@ -27,6 +27,8 @@ import { replaceableComponent } from "../../../../utils/replaceableComponent";
import ErrorDialog from "../../dialogs/ErrorDialog";
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
import { logger } from "matrix-js-sdk/src/logger";
/*
TODO: Improve the UX for everything in here.
It's very much placeholder, but it gets the job done. The old way of handling
@ -78,7 +80,7 @@ export class ExistingEmailAddress extends React.Component<IExistingEmailAddressP
MatrixClientPeg.get().deleteThreePid(this.props.email.medium, this.props.email.address).then(() => {
return this.props.onRemoved(this.props.email);
}).catch((err) => {
console.error("Unable to remove contact information: " + err);
logger.error("Unable to remove contact information: " + err);
Modal.createTrackedDialog('Remove 3pid failed', '', ErrorDialog, {
title: _t("Unable to remove contact information"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
@ -181,7 +183,7 @@ export default class EmailAddresses extends React.Component<IProps, IState> {
task.addEmailAddress(email).then(() => {
this.setState({ continueDisabled: false });
}).catch((err) => {
console.error("Unable to add email address " + email + " " + err);
logger.error("Unable to add email address " + email + " " + err);
this.setState({ verifying: false, continueDisabled: false, addTask: null });
Modal.createTrackedDialog('Unable to add email address', '', ErrorDialog, {
title: _t("Unable to add email address"),
@ -221,7 +223,7 @@ export default class EmailAddresses extends React.Component<IProps, IState> {
"and then click continue again."),
});
} else {
console.error("Unable to verify email address: ", err);
logger.error("Unable to verify email address: ", err);
Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, {
title: _t("Unable to verify email address."),
description: ((err && err.message) ? err.message : _t("Operation failed")),

View file

@ -28,6 +28,8 @@ import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
import ErrorDialog from "../../dialogs/ErrorDialog";
import { PhoneNumberCountryDefinition } from "../../../../phonenumber";
import { logger } from "matrix-js-sdk/src/logger";
/*
TODO: Improve the UX for everything in here.
This is a copy/paste of EmailAddresses, mostly.
@ -74,7 +76,7 @@ export class ExistingPhoneNumber extends React.Component<IExistingPhoneNumberPro
MatrixClientPeg.get().deleteThreePid(this.props.msisdn.medium, this.props.msisdn.address).then(() => {
return this.props.onRemoved(this.props.msisdn);
}).catch((err) => {
console.error("Unable to remove contact information: " + err);
logger.error("Unable to remove contact information: " + err);
Modal.createTrackedDialog('Remove 3pid failed', '', ErrorDialog, {
title: _t("Unable to remove contact information"),
description: ((err && err.message) ? err.message : _t("Operation failed")),
@ -183,7 +185,7 @@ export default class PhoneNumbers extends React.Component<IProps, IState> {
task.addMsisdn(phoneCountry, phoneNumber).then((response) => {
this.setState({ continueDisabled: false, verifyMsisdn: response.msisdn });
}).catch((err) => {
console.error("Unable to add phone number " + phoneNumber + " " + err);
logger.error("Unable to add phone number " + phoneNumber + " " + err);
this.setState({ verifying: false, continueDisabled: false, addTask: null });
Modal.createTrackedDialog('Add Phone Number Error', '', ErrorDialog, {
title: _t("Error"),
@ -221,7 +223,7 @@ export default class PhoneNumbers extends React.Component<IProps, IState> {
}).catch((err) => {
this.setState({ continueDisabled: false });
if (err.errcode !== 'M_THREEPID_AUTH_FAILED') {
console.error("Unable to verify phone number: " + err);
logger.error("Unable to verify phone number: " + err);
Modal.createTrackedDialog('Unable to verify phone number', '', ErrorDialog, {
title: _t("Unable to verify phone number."),
description: ((err && err.message) ? err.message : _t("Operation failed")),

View file

@ -26,6 +26,8 @@ import { IThreepid } from "matrix-js-sdk/src/@types/threepids";
import ErrorDialog from "../../dialogs/ErrorDialog";
import AccessibleButton from "../../elements/AccessibleButton";
import { logger } from "matrix-js-sdk/src/logger";
/*
TODO: Improve the UX for everything in here.
It's very much placeholder, but it gets the job done. The old way of handling
@ -98,7 +100,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
}
this.setState({ bound: bind });
} catch (err) {
console.error(`Unable to ${label} email address ${address} ${err}`);
logger.error(`Unable to ${label} email address ${address} ${err}`);
this.setState({
verifying: false,
continueDisabled: false,
@ -133,7 +135,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
bound: bind,
});
} catch (err) {
console.error(`Unable to ${label} email address ${address} ${err}`);
logger.error(`Unable to ${label} email address ${address} ${err}`);
this.setState({
verifying: false,
continueDisabled: false,
@ -187,7 +189,7 @@ export class EmailAddress extends React.Component<IEmailAddressProps, IEmailAddr
"and then click continue again."),
});
} else {
console.error("Unable to verify email address: " + err);
logger.error("Unable to verify email address: " + err);
Modal.createTrackedDialog('Unable to verify email address', '', ErrorDialog, {
title: _t("Unable to verify email address."),
description: ((err && err.message) ? err.message : _t("Operation failed")),

View file

@ -27,6 +27,8 @@ import ErrorDialog from "../../dialogs/ErrorDialog";
import Field from "../../elements/Field";
import AccessibleButton from "../../elements/AccessibleButton";
import { logger } from "matrix-js-sdk/src/logger";
/*
TODO: Improve the UX for everything in here.
This is a copy/paste of EmailAddresses, mostly.
@ -98,7 +100,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
}
this.setState({ bound: bind });
} catch (err) {
console.error(`Unable to ${label} phone number ${address} ${err}`);
logger.error(`Unable to ${label} phone number ${address} ${err}`);
this.setState({
verifying: false,
continueDisabled: false,
@ -137,7 +139,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
bound: bind,
});
} catch (err) {
console.error(`Unable to ${label} phone number ${address} ${err}`);
logger.error(`Unable to ${label} phone number ${address} ${err}`);
this.setState({
verifying: false,
continueDisabled: false,
@ -194,7 +196,7 @@ export class PhoneNumber extends React.Component<IPhoneNumberProps, IPhoneNumber
} catch (err) {
this.setState({ continueDisabled: false });
if (err.errcode !== 'M_THREEPID_AUTH_FAILED') {
console.error("Unable to verify phone number: " + err);
logger.error("Unable to verify phone number: " + err);
Modal.createTrackedDialog('Unable to verify phone number', '', ErrorDialog, {
title: _t("Unable to verify phone number."),
description: ((err && err.message) ? err.message : _t("Operation failed")),

View file

@ -23,6 +23,8 @@ import SettingsStore from '../../../../../settings/SettingsStore';
import { SettingLevel } from "../../../../../settings/SettingLevel";
import { replaceableComponent } from "../../../../../utils/replaceableComponent";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
roomId: string;
}
@ -83,10 +85,10 @@ export default class NotificationsSettingsTab extends React.Component<IProps, IS
try {
await this.saveSound();
} catch (ex) {
console.error(
logger.error(
`Unable to save notification sound for ${this.props.roomId}`,
);
console.error(ex);
logger.error(ex);
}
};

View file

@ -28,6 +28,8 @@ import { compare } from "../../../../../utils/strings";
import ErrorDialog from '../../../dialogs/ErrorDialog';
import PowerSelector from "../../../elements/PowerSelector";
import { logger } from "matrix-js-sdk/src/logger";
interface IEventShowOpts {
isState?: boolean;
hideForSpace?: boolean;
@ -72,7 +74,7 @@ interface IBannedUserProps {
export class BannedUser extends React.Component<IBannedUserProps> {
private onUnbanClick = (e) => {
MatrixClientPeg.get().unban(this.props.member.roomId, this.props.member.userId).catch((err) => {
console.error("Failed to unban: " + err);
logger.error("Failed to unban: " + err);
Modal.createTrackedDialog('Failed to unban', '', ErrorDialog, {
title: _t('Error'),
description: _t('Failed to unban'),
@ -167,7 +169,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
}
client.sendStateEvent(this.props.roomId, EventType.RoomPowerLevels, plContent).catch(e => {
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Power level requirement change failed', '', ErrorDialog, {
title: _t('Error changing power level requirement'),
@ -193,7 +195,7 @@ export default class RolesRoomSettingsTab extends React.Component<IProps> {
plContent['users'][powerLevelKey] = value;
client.sendStateEvent(this.props.roomId, EventType.RoomPowerLevels, plContent).catch(e => {
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Power level change failed', '', ErrorDialog, {
title: _t('Error changing power level'),

View file

@ -36,6 +36,8 @@ import CreateRoomDialog from '../../../dialogs/CreateRoomDialog';
import JoinRuleSettings from "../../JoinRuleSettings";
import ErrorDialog from "../../../dialogs/ErrorDialog";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
roomId: string;
closeSettingsFn: () => void;
@ -180,7 +182,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
this.props.roomId, EventType.RoomEncryption,
{ algorithm: "m.megolm.v1.aes-sha2" },
).catch((e) => {
console.error(e);
logger.error(e);
this.setState({ encrypted: beforeEncrypted });
});
},
@ -198,7 +200,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
client.sendStateEvent(this.props.roomId, EventType.RoomGuestAccess, {
guest_access: guestAccess,
}, "").catch((e) => {
console.error(e);
logger.error(e);
this.setState({ guestAccess: beforeGuestAccess });
});
};
@ -225,7 +227,7 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
MatrixClientPeg.get().sendStateEvent(this.props.roomId, EventType.RoomHistoryVisibility, {
history_visibility: history,
}, "").catch((e) => {
console.error(e);
logger.error(e);
this.setState({ history: beforeHistory });
});
};

View file

@ -41,6 +41,8 @@ import { replaceableComponent } from "../../../../../utils/replaceableComponent"
import { compare } from "../../../../../utils/strings";
import LayoutSwitcher from "../../LayoutSwitcher";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
}
@ -225,7 +227,7 @@ export default class AppearanceUserSettingsTab extends React.Component<IProps, I
}
currentThemes.push(themeInfo);
} catch (e) {
console.error(e);
logger.error(e);
this.setState({ customThemeMessage: { text: _t("Error downloading theme information."), isError: true } });
return; // Don't continue on error
}

View file

@ -50,6 +50,8 @@ import InlineTermsAgreement from "../../../terms/InlineTermsAgreement";
import SetIdServer from "../../SetIdServer";
import SetIntegrationManager from "../../SetIntegrationManager";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
closeSettingsFn: () => void;
}
@ -253,7 +255,7 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
} else if (!errMsg) {
errMsg += ` (HTTP status ${err.httpStatus})`;
}
console.error("Failed to change password: " + errMsg);
logger.error("Failed to change password: " + errMsg);
Modal.createTrackedDialog('Failed to change password', '', ErrorDialog, {
title: _t("Error"),
description: errMsg,

View file

@ -58,10 +58,10 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
componentDidMount(): void {
PlatformPeg.get().getAppVersion().then((ver) => this.setState({ appVersion: ver })).catch((e) => {
console.error("Error getting vector version: ", e);
logger.error("Error getting vector version: ", e);
});
PlatformPeg.get().canSelfUpdate().then((v) => this.setState({ canUpdate: v })).catch((e) => {
console.error("Error getting self updatability: ", e);
logger.error("Error getting self updatability: ", e);
});
}

View file

@ -28,6 +28,8 @@ import QuestionDialog from "../../../dialogs/QuestionDialog";
import AccessibleButton from "../../../elements/AccessibleButton";
import Field from "../../../elements/Field";
import { logger } from "matrix-js-sdk/src/logger";
interface IState {
busy: boolean;
newPersonalRule: string;
@ -69,7 +71,7 @@ export default class MjolnirUserSettingsTab extends React.Component<{}, IState>
await list.banEntity(kind, this.state.newPersonalRule, _t("Ignored/Blocked"));
this.setState({ newPersonalRule: "" }); // this will also cause the new rule to be rendered
} catch (e) {
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Failed to add Mjolnir rule', '', ErrorDialog, {
title: _t('Error adding ignored user/server'),
@ -90,7 +92,7 @@ export default class MjolnirUserSettingsTab extends React.Component<{}, IState>
await Mjolnir.sharedInstance().subscribeToList(room.roomId);
this.setState({ newList: "" }); // this will also cause the new rule to be rendered
} catch (e) {
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Failed to subscribe to Mjolnir list', '', ErrorDialog, {
title: _t('Error subscribing to list'),
@ -107,7 +109,7 @@ export default class MjolnirUserSettingsTab extends React.Component<{}, IState>
const list = Mjolnir.sharedInstance().getPersonalList();
await list.unbanEntity(rule.kind, rule.entity);
} catch (e) {
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Failed to remove Mjolnir rule', '', ErrorDialog, {
title: _t('Error removing ignored user/server'),
@ -124,7 +126,7 @@ export default class MjolnirUserSettingsTab extends React.Component<{}, IState>
await Mjolnir.sharedInstance().unsubscribeFromList(list.roomId);
await MatrixClientPeg.get().leave(list.roomId);
} catch (e) {
console.error(e);
logger.error(e);
Modal.createTrackedDialog('Failed to unsubscribe from Mjolnir list', '', ErrorDialog, {
title: _t('Error unsubscribing from list'),

View file

@ -39,6 +39,8 @@ import { Action } from "../../../dispatcher/actions";
import { UserTab } from "../dialogs/UserSettingsDialog";
import { Key } from "../../../Keyboard";
import { logger } from "matrix-js-sdk/src/logger";
export const createSpace = async (
name: string,
isPublic: boolean,
@ -255,7 +257,7 @@ const SpaceCreateMenu = ({ onFinished }) => {
onFinished();
} catch (e) {
console.error(e);
logger.error(e);
}
};

View file

@ -27,6 +27,8 @@ import { IDialogProps } from "../dialogs/IDialogProps";
import { getTopic } from "../elements/RoomTopic";
import { leaveSpace } from "../../../utils/space";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps extends IDialogProps {
matrixClient: MatrixClient;
space: Room;
@ -83,7 +85,7 @@ const SpaceSettingsGeneralTab = ({ matrixClient: cli, space, onFinished }: IProp
setBusy(false);
const failures = results.filter(r => r.status === "rejected");
if (failures.length > 0) {
console.error("Failed to save space settings: ", failures);
logger.error("Failed to save space settings: ", failures);
setError(_t("Failed to save space settings."));
}
};

View file

@ -31,6 +31,8 @@ import { Action } from "../../../dispatcher/actions";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import VerificationRequestDialog from "../dialogs/VerificationRequestDialog";
import { logger } from "matrix-js-sdk/src/logger";
interface IProps {
toastKey: string;
request: VerificationRequest;
@ -98,7 +100,7 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
try {
this.props.request.cancel();
} catch (err) {
console.error("Error while cancelling verification request", err);
logger.error("Error while cancelling verification request", err);
}
};
@ -132,7 +134,7 @@ export default class VerificationRequestToast extends React.PureComponent<IProps
}
await request.accept();
} catch (err) {
console.error(err.message);
logger.error(err.message);
}
};

View file

@ -66,7 +66,7 @@ export default class AudioFeed extends React.Component<IProps, IState> {
// back to the default after the call is over - Dave
element.setSinkId(audioOutput);
} catch (e) {
console.error("Couldn't set requested audio output device: using default", e);
logger.error("Couldn't set requested audio output device: using default", e);
logger.warn("Couldn't set requested audio output device: using default", e);
}
}

View file

@ -46,6 +46,8 @@ import { Action } from "./dispatcher/actions";
import ErrorDialog from "./components/views/dialogs/ErrorDialog";
import Spinner from "./components/views/elements/Spinner";
import { logger } from "matrix-js-sdk/src/logger";
// we define a number of interfaces which take their names from the js-sdk
/* eslint-disable camelcase */
@ -278,7 +280,7 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
action: Action.JoinRoomError,
roomId,
});
console.error("Failed to create room " + roomId + " " + err);
logger.error("Failed to create room " + roomId + " " + err);
let description = _t("Server may be unavailable, overloaded, or you hit a bug.");
if (err.errcode === "M_UNSUPPORTED_ROOM_VERSION") {
// Technically not possible with the UI as of April 2019 because there's no
@ -356,7 +358,7 @@ export async function canEncryptToAllUsers(client: MatrixClient, userIds: string
Object.keys(userDevices).length > 0,
);
} catch (e) {
console.error("Error determining if it's possible to encrypt to all users: ", e);
logger.error("Error determining if it's possible to encrypt to all users: ", e);
return false; // assume not
}
}

View file

@ -24,6 +24,8 @@ import SettingsStore from "../settings/SettingsStore";
import IntegrationManager from "../components/views/settings/IntegrationManager";
import { IntegrationManagers } from "./IntegrationManagers";
import { logger } from "matrix-js-sdk/src/logger";
export enum Kind {
Account = "account",
Config = "config",
@ -94,7 +96,7 @@ export class IntegrationManagerInstance {
return;
}
console.error(e);
logger.error(e);
newProps["connected"] = false;
}

Some files were not shown because too many files have changed in this diff Show more