diff --git a/src/Utils.cpp b/src/Utils.cpp index 5e26dfdf..94f80e57 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -112,6 +112,12 @@ std::optional getFromString(char const* val) return res; } +template +char const* getTypename(); + +template<> +char const* getTypename() { return "float"; } + template std::pair Utils::getJsonValueByPath(JsonDocument const& root, String const& path) { @@ -179,15 +185,17 @@ std::pair Utils::getJsonValueByPath(JsonDocument const& root, String } if (!value.is()) { - snprintf(errBuffer, kErrBufferSize, "Value '%s' at JSON path '%s' is not " - "of the expected type", value.as().c_str(), path.c_str()); + snprintf(errBuffer, kErrBufferSize, "Value '%s' at JSON path '%s' is " + "neither a string nor of type %s", value.as().c_str(), + path.c_str(), getTypename()); return { T(), String(errBuffer) }; } auto res = getFromString(value.as()); if (!res.has_value()) { snprintf(errBuffer, kErrBufferSize, "String '%s' at JSON path '%s' cannot " - "be converted to the expected type", value.as().c_str(), path.c_str()); + "be converted to %s", value.as().c_str(), path.c_str(), + getTypename()); return { T(), String(errBuffer) }; }