From 4b364041153432a748edba382b173c30115a4d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=B3r=C3=A1nt=20Pint=C3=A9r?= Date: Tue, 12 Nov 2024 09:20:08 +0100 Subject: [PATCH] Accept empty configuration as no configuration Sometimes the server sends an empty string instead of ull, let's handle these the same. --- main/kernel/Configuration.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main/kernel/Configuration.hpp b/main/kernel/Configuration.hpp index 4098765f..67552e20 100644 --- a/main/kernel/Configuration.hpp +++ b/main/kernel/Configuration.hpp @@ -290,8 +290,15 @@ class ConfigurationFile { JsonDocument json; DeserializationError error = deserializeJson(json, file); file.close(); - if (error) { - throw ConfigurationException("Cannot open config file " + path + " (" + String(error.c_str()) + ")"); + switch (error.code()) { + case DeserializationError::Code::Ok: + break; + case DeserializationError::Code::EmptyInput: + Log.debug("The configuration file '%s' is empty, falling back to defaults", + path.c_str()); + break; + default: + throw ConfigurationException("Cannot open config file " + path + " (" + String(error.c_str()) + ")"); } update(json.as()); Log.info("Effective configuration for '%s': %s",