Replace newTranslatableError
with UserFriendlyError
(#10440
* Introduce UserFriendlyError * Replace newTranslatableError with UserFriendlyError * Remove ITranslatableError * Fix up some strict lints * Document when we/why we can remove * Update matrix-web-i18n Includes changes to find `new UserFriendlyError`, see https://github.com/matrix-org/matrix-web-i18n/pull/6 * Include room ID in error * Translate fallback error * Translate better * Update i18n strings * Better re-use * Minor comment fixes
This commit is contained in:
parent
567248d5c5
commit
ff1468b6d3
10 changed files with 285 additions and 99 deletions
|
@ -21,7 +21,7 @@ import { IContent } from "matrix-js-sdk/src/models/event";
|
|||
import EditorModel from "./model";
|
||||
import { Type } from "./parts";
|
||||
import { Command, CommandCategories, getCommand } from "../SlashCommands";
|
||||
import { ITranslatableError, _t, _td } from "../languageHandler";
|
||||
import { UserFriendlyError, _t, _td } from "../languageHandler";
|
||||
import Modal from "../Modal";
|
||||
import ErrorDialog from "../components/views/dialogs/ErrorDialog";
|
||||
import QuestionDialog from "../components/views/dialogs/QuestionDialog";
|
||||
|
@ -65,7 +65,7 @@ export async function runSlashCommand(
|
|||
): Promise<[content: IContent | null, success: boolean]> {
|
||||
const result = cmd.run(roomId, threadId, args);
|
||||
let messageContent: IContent | null = null;
|
||||
let error = result.error;
|
||||
let error: any = result.error;
|
||||
if (result.promise) {
|
||||
try {
|
||||
if (cmd.category === CommandCategories.messages || cmd.category === CommandCategories.effects) {
|
||||
|
@ -86,9 +86,8 @@ export async function runSlashCommand(
|
|||
let errText;
|
||||
if (typeof error === "string") {
|
||||
errText = error;
|
||||
} else if ((error as ITranslatableError).translatedMessage) {
|
||||
// Check for translatable errors (newTranslatableError)
|
||||
errText = (error as ITranslatableError).translatedMessage;
|
||||
} else if (error instanceof UserFriendlyError) {
|
||||
errText = error.translatedMessage;
|
||||
} else if (error.message) {
|
||||
errText = error.message;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue