Skip to content

Commit

Permalink
fix: 🐛 manifest_string() panics when no manifest available (#189)
Browse files Browse the repository at this point in the history
* fix: 🐛 manifest_string() panics when no manifest available

* chore: 🤖 fix failing test
  • Loading branch information
theashraf authored Jun 25, 2024
1 parent 359c2ce commit 5ee7034
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions dotlottie-rs/src/dotlottie_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,10 @@ impl DotLottiePlayerContainer {
}

pub fn manifest_string(&self) -> String {
self.runtime.read().unwrap().manifest().unwrap().to_string()
}
self.runtime.try_read().ok()
.and_then(|runtime| runtime.manifest())
.map_or_else(String::new, |manifest| manifest.to_string())
}

pub fn is_complete(&self) -> bool {
self.runtime.read().unwrap().is_complete()
Expand Down Expand Up @@ -1752,7 +1754,7 @@ impl DotLottiePlayer {
}

pub fn manifest_string(&self) -> String {
self.player.read().unwrap().manifest_string()
self.player.try_read().map_or_else(|_| String::new(), |player| player.manifest_string())
}

pub fn is_complete(&self) -> bool {
Expand Down

0 comments on commit 5ee7034

Please sign in to comment.