aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2023-08-20 23:52:01 -0500
committermat <git@matdoes.dev>2023-08-20 23:52:01 -0500
commit1b6e0244606cf7917e68918d32928550aabf85b0 (patch)
treeceb73e49db1bcecc8d395f350c47539abe0f47e4
parente511ad3c31842fbb3b4d09ba0ea99b8a9caaefb0 (diff)
downloadazalea-drasl-1b6e0244606cf7917e68918d32928550aabf85b0.tar.xz
don't panic if TranslatableComponent::to_string fails
-rwxr-xr-xazalea-chat/src/translatable_component.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs
index eb8abcdc..a1c72e35 100755
--- a/azalea-chat/src/translatable_component.rs
+++ b/azalea-chat/src/translatable_component.rs
@@ -133,7 +133,10 @@ impl Display for TranslatableComponent {
for component in FormattedText::Translatable(self.clone()).into_iter() {
let component_text = match &component {
FormattedText::Text(c) => c.text.to_string(),
- FormattedText::Translatable(c) => c.read()?.to_string(),
+ FormattedText::Translatable(c) => match c.read() {
+ Ok(c) => c.to_string(),
+ Err(_) => c.key.to_string(),
+ },
};
f.write_str(&component_text)?;