mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
AK: Print a better error message when missing a SourceGenerator key
Previously, if you forgot to set a key on a SourceGenerator, you would get this less-than-helpful error message: > Generate_CSS_MediaFeatureID_cpp: /home/sam/serenity/Meta/Lagom/../../AK/Optional.h:174: T AK::Optional<T>::release_value() [with T = AK::String]: Assertion `m_has_value' failed. Now, it instead looks like this: > No key named `name:titlecase` set on SourceGenerator Generate_CSS_MediaFeatureID_cpp: /home/sam/serenity/Meta/Lagom/../../AK/SourceGenerator.h:44: AK::String AK::SourceGenerator::get(AK::StringView) const: Assertion `false' failed.
This commit is contained in:
parent
12561327d6
commit
a451810599
Notes:
sideshowbarker
2024-07-17 17:38:36 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/a451810599 Pull-request: https://github.com/SerenityOS/serenity/pull/12971
@ -36,7 +36,15 @@ public:
|
||||
SourceGenerator fork() { return SourceGenerator { m_builder, m_mapping, m_opening, m_closing }; }
|
||||
|
||||
void set(StringView key, String value) { m_mapping.set(key, value); }
|
||||
String get(StringView key) const { return m_mapping.get(key).value(); }
|
||||
String get(StringView key) const
|
||||
{
|
||||
auto result = m_mapping.get(key);
|
||||
if (!result.has_value()) {
|
||||
warnln("No key named `{}` set on SourceGenerator", key);
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
return result.release_value();
|
||||
}
|
||||
|
||||
StringView as_string_view() const { return m_builder.string_view(); }
|
||||
String as_string() const { return m_builder.build(); }
|
||||
|
Loading…
Reference in New Issue
Block a user