Skip to content

Commit 98187e4

Browse files
committed
chore: further improved logs when global settings file is corrupted
1 parent 60e461d commit 98187e4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/backend/common/profile-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class ProfileManager {
109109
globalSettingsDb.push("/profiles/loggedInProfile", profileId);
110110
logger.info(`New profile created: ${profileId}.${restart ? " Restarting." : ""}`);
111111
} catch (error) {
112-
logger.error(`Error saving ${profileId} profile to global settings. Is the file locked or corrupted?`, error);
112+
const errorMessage = (error as Error).name === "DatabaseError" ? error?.inner?.message ?? error.stack : error;
113+
logger.error(`Error saving ${profileId} profile to global settings. Is the file locked or corrupted?`, errorMessage);
113114
dialog.showErrorBox("Error Loading Profile", `An error occurred while trying to load your ${profileId} profile. Please try starting Firebot again. If this issue continues, please reach out on our Discord for support.`);
114115
app.quit();
115116
return;

src/backend/common/settings-manager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ class SettingsManager extends EventEmitter {
139139
if (defaultValue !== undefined) {
140140
this.settingsCache[settingPath] = defaultValue;
141141
}
142-
if ((err as Error).name !== "DataError") {
142+
if ((err as Error).name === "DatabaseError") {
143+
logger.error(`Failed to read "${settingPath}" in global settings file. File may be corrupt.`, err?.inner?.message ?? err.stack);
144+
} else if ((err as Error).name !== "DataError") {
143145
logger.warn(err);
144146
}
145147
}

0 commit comments

Comments
 (0)