Print error message for invalid color strings
This commit is contained in:
parent
c9efd09f71
commit
eeab4f0d45
@ -105,6 +105,9 @@ class config {
|
||||
return dereference<T>(move(section), move(key), move(string_value), move(result));
|
||||
} catch (const key_error& err) {
|
||||
return default_value;
|
||||
} catch (const value_error& err) {
|
||||
m_log.err("Invalid value for \"%s.%s\", using default value (reason: %s)", section, key, err.what());
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,6 +168,9 @@ class config {
|
||||
}
|
||||
} catch (const key_error& err) {
|
||||
break;
|
||||
} catch (const value_error& err) {
|
||||
m_log.err("Invalid value in list \"%s.%s\", using list as-is (reason: %s)", section, key, err.what());
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ class signal_emitter {
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
logger::make().err(e.what());
|
||||
logger::make().err("Signal receiver raised an exception: %s", e.what());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -201,7 +201,13 @@ chrono::duration<double> config::convert(string&& value) const {
|
||||
|
||||
template <>
|
||||
rgba config::convert(string&& value) const {
|
||||
return rgba{value};
|
||||
rgba ret{value};
|
||||
|
||||
if (!ret.has_color()) {
|
||||
throw value_error("\"" + value + "\" is an invalid color value.");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -224,6 +224,10 @@ rgba parser::parse_color(const string& s, rgba fallback) {
|
||||
rgba ret = rgba{s};
|
||||
|
||||
if (!ret.has_color() || ret.m_type == rgba::ALPHA_ONLY) {
|
||||
logger::make().warn(
|
||||
"Invalid color in formatting tag detected: \"%s\", using fallback \"%s\". This is an issue with one of your "
|
||||
"formatting tags. If it is not, please report this as a bug.",
|
||||
s, static_cast<string>(fallback));
|
||||
return fallback;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,6 @@ rgba::rgba(string hex) {
|
||||
hex = normalize_hex(hex);
|
||||
|
||||
if (hex.length() == 0) {
|
||||
// TODO we need a way to inform the user that their color was malformed
|
||||
m_value = 0;
|
||||
m_type = NONE;
|
||||
} else if (hex.length() == 2) {
|
||||
|
Loading…
Reference in New Issue
Block a user