Skip to content

Commit 664d8cc

Browse files
authored
fix: remove unwrap causing crash (#96)
1 parent 0bb001e commit 664d8cc

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

crates/bevy_animation_graph/src/nodes/clip_node.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ impl ClipNode {
4343
}
4444

4545
#[inline]
46-
pub fn clip_duration(&self, ctx: &PassContext) -> f32 {
46+
pub fn clip_duration(&self, ctx: &PassContext) -> Result<f32, GraphError> {
4747
if let Some(duration) = self.override_duration {
48-
duration
48+
Ok(duration)
4949
} else {
5050
ctx.resources
5151
.graph_clip_assets
5252
.get(&self.clip)
53-
.unwrap()
54-
.duration()
53+
.ok_or(GraphError::ClipMissing)
54+
.map(|c| c.duration())
5555
}
5656
}
5757

@@ -72,12 +72,12 @@ impl ClipNode {
7272

7373
impl NodeLike for ClipNode {
7474
fn duration(&self, mut ctx: PassContext) -> Result<(), GraphError> {
75-
ctx.set_duration_fwd(Some(self.clip_duration(&ctx)));
75+
ctx.set_duration_fwd(Some(self.clip_duration(&ctx)?));
7676
Ok(())
7777
}
7878

7979
fn update(&self, mut ctx: PassContext) -> Result<(), GraphError> {
80-
let clip_duration = self.clip_duration(&ctx);
80+
let clip_duration = self.clip_duration(&ctx)?;
8181

8282
let Some(clip) = ctx.resources.graph_clip_assets.get(&self.clip) else {
8383
// TODO: Should we propagate a GraphError instead?

0 commit comments

Comments
 (0)