config: throw an error explicitly when parsing colors in gradients

ref #8552
This commit is contained in:
Vaxry 2024-11-24 02:46:24 +00:00
parent 54f57797e9
commit 55ec8bd512

View file

@ -67,7 +67,10 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
} }
try { try {
DATA->m_vColors.push_back(CColor(*configStringToInt(var))); const auto COL = configStringToInt(var);
if (!COL)
throw std::runtime_error(std::format("failed to parse {} as a color", var));
DATA->m_vColors.push_back(CColor(COL.value()));
} catch (std::exception& e) { } catch (std::exception& e) {
Debug::log(WARN, "Error parsing gradient {}", V); Debug::log(WARN, "Error parsing gradient {}", V);
parseError = "Error parsing gradient " + V + ": " + e.what(); parseError = "Error parsing gradient " + V + ": " + e.what();