feat: improve error toasts
This commit is contained in:
parent
3e1b235a75
commit
ef00097a51
2 changed files with 8 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -123,6 +123,11 @@ void RootConfig::saveToFile() {
|
|||
std::optional<QString> 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<QString> 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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue