mirror of https://github.com/vector-im/riot-web
Merge pull request #3580 from matrix-org/t3chguy/better_slash_command_errors_unknown
Fix error message which is shown when unknown slash command attemptedpull/21833/head
commit
bc263fa4bb
|
@ -37,7 +37,7 @@ import SendHistoryManager from "../../../SendHistoryManager";
|
||||||
import {processCommandInput} from '../../../SlashCommands';
|
import {processCommandInput} from '../../../SlashCommands';
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import { _t } from '../../../languageHandler';
|
import {_t, _td} from '../../../languageHandler';
|
||||||
import ContentMessages from '../../../ContentMessages';
|
import ContentMessages from '../../../ContentMessages';
|
||||||
import {Key} from "../../../Keyboard";
|
import {Key} from "../../../Keyboard";
|
||||||
|
|
||||||
|
@ -214,12 +214,20 @@ export default class SendMessageComposer extends React.Component {
|
||||||
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
// assume the error is a server error when the command is async
|
// assume the error is a server error when the command is async
|
||||||
const isServerError = !!cmd.promise;
|
const isServerError = !!cmd.promise;
|
||||||
const title = isServerError ? "Server error" : "Command error";
|
const title = isServerError ? _td("Server error") : _td("Command error");
|
||||||
|
|
||||||
|
let errText;
|
||||||
|
if (typeof error === 'string') {
|
||||||
|
errText = error;
|
||||||
|
} else if (error.message) {
|
||||||
|
errText = error.message;
|
||||||
|
} else {
|
||||||
|
errText = _t("Server unavailable, overloaded, or something else went wrong.");
|
||||||
|
}
|
||||||
|
|
||||||
Modal.createTrackedDialog(title, '', ErrorDialog, {
|
Modal.createTrackedDialog(title, '', ErrorDialog, {
|
||||||
title: isServerError ? _t("Server error") : _t("Command error"),
|
title: _t(title),
|
||||||
description: error.message ? error.message : _t(
|
description: errText,
|
||||||
"Server unavailable, overloaded, or something else went wrong.",
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("Command success.");
|
console.log("Command success.");
|
||||||
|
|
Loading…
Reference in New Issue