chore: error handling

This commit is contained in:
Lewis Crichton 2023-12-27 17:53:06 +00:00
parent 85b510b881
commit 669c7f3964
No known key found for this signature in database
2 changed files with 12 additions and 2 deletions

View file

@ -19,8 +19,10 @@
import { addSettingsListener, Settings } from "@api/Settings";
import { Toasts } from "@webpack/common";
import { Logger } from "./Logger";
import { compileUsercss } from "./themes/usercss/compiler";
const logger = new Logger("QuickCSS");
let style: HTMLStyleElement;
let themesStyle: HTMLStyleElement;
@ -66,7 +68,11 @@ async function initThemes() {
if (IS_WEB) {
for (const theme of enabledThemes) {
const themeData = await VencordNative.themes.getThemeData(theme);
try {
var themeData = await VencordNative.themes.getThemeData(theme);
} catch (e) {
logger.error("Failed to get theme data for", theme, e);
}
if (!themeData) continue;
const blob = new Blob([themeData], { type: "text/css" });

View file

@ -55,7 +55,11 @@ const preprocessors: { [preprocessor: string]: (text: string, vars: Record<strin
};
export async function compileUsercss(fileName: string) {
const themeData = await VencordNative.themes.getThemeData(fileName);
try {
var themeData = await VencordNative.themes.getThemeData(fileName);
} catch (e) {
UserCSSLogger.error("Failed to get theme data for", fileName, e);
}
if (!themeData) return null;
// UserCSS preprocessor order look like this: