mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00: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
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		|  | @ -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…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins