EmoteCloner: make the error toasts useful (#1938)

Co-authored-by: Vendicated <vendicated@riseup.net>
This commit is contained in:
Haruka 2023-11-01 03:23:45 +02:00 committed by GitHub
parent 9de6c2d4ff
commit 5dc0d06be1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -155,10 +155,15 @@ async function doClone(guildId: string, data: Sticker | Emoji) {
type: Toasts.Type.SUCCESS, type: Toasts.Type.SUCCESS,
id: Toasts.genId() id: Toasts.genId()
}); });
} catch (e) { } catch (e: any) {
let message = "Something went wrong (check console!)";
try {
message = JSON.parse(e.text).message;
} catch { }
new Logger("EmoteCloner").error("Failed to clone", data.name, "to", guildId, e); new Logger("EmoteCloner").error("Failed to clone", data.name, "to", guildId, e);
Toasts.show({ Toasts.show({
message: "Oopsie something went wrong :( Check console!!!", message: "Failed to clone: " + message,
type: Toasts.Type.FAILURE, type: Toasts.Type.FAILURE,
id: Toasts.genId() id: Toasts.genId()
}); });