diff --git a/modules/ConfigToasts.qml b/modules/ConfigToasts.qml index 7c43e522..2e0f5fec 100644 --- a/modules/ConfigToasts.qml +++ b/modules/ConfigToasts.qml @@ -11,7 +11,7 @@ Scope { } function onLoadFailed(error: string): void { - Toaster.toast(qsTr("Failed to read config file"), error, "settings_alert", Toast.Warning); + Toaster.toast(qsTr("Failed to parse config"), error, "settings_alert", Toast.Warning); } function onSaveFailed(error: string): void { @@ -23,7 +23,7 @@ Scope { Connections { function onLoadFailed(error: string): void { - Toaster.toast(qsTr("Failed to read token config file"), error, "settings_alert", Toast.Warning); + Toaster.toast(qsTr("Failed to parse token config"), error, "settings_alert", Toast.Warning); } target: TokenConfig diff --git a/plugin/src/Caelestia/Config/rootconfig.cpp b/plugin/src/Caelestia/Config/rootconfig.cpp index 79eaf37e..bc3d1cdc 100644 --- a/plugin/src/Caelestia/Config/rootconfig.cpp +++ b/plugin/src/Caelestia/Config/rootconfig.cpp @@ -123,6 +123,11 @@ void RootConfig::saveToFile() { std::optional RootConfig::reloadFromFile() { QFile file(m_filePath); + if (!file.exists()) { + qCDebug(lcConfig) << "File does not exist:" << m_filePath; + return std::nullopt; + } + if (!file.open(QIODevice::ReadOnly)) { auto err = QStringLiteral("Failed to open %1: %2").arg(m_filePath, file.errorString()); qCDebug(lcConfig, "%s", qUtf8Printable(err)); @@ -143,7 +148,7 @@ std::optional RootConfig::reloadFromFile() { qCWarning(lcConfig, "Failed to parse %s: %s", qUtf8Printable(m_filePath), qUtf8Printable(error.errorString())); m_parseRetries = 0; - return error.errorString(); + return QStringLiteral("JSON parse error: %1").arg(error.errorString()); } m_parseRetries = 0;