Make slash command errors translatable but also work in rageshakes (#7377)

See https://github.com/matrix-org/matrix-react-sdk/pull/7372#discussion_r769556546

We want the error to be translated for the user but not in our rageshake logs.

Also updates some error messages to give more info.
This commit is contained in:
Eric Eastwood 2022-01-11 12:25:28 -06:00 committed by GitHub
parent 53a72dafa9
commit 038a6bc204
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 91 additions and 40 deletions

View file

@ -53,9 +53,9 @@ interface ITranslatableError extends Error {
* @param {string} message Message to translate.
* @returns {Error} The constructed error.
*/
export function newTranslatableError(message: string) {
export function newTranslatableError(message: string, variables?: IVariables): ITranslatableError {
const error = new Error(message) as ITranslatableError;
error.translatedMessage = _t(message);
error.translatedMessage = _t(message, variables);
return error;
}