Skip to content

Commit a7681d2

Browse files
committed
improve panic message if not running on render app
1 parent 7552198 commit a7681d2

File tree

1 file changed

+9
-4
lines changed
  • crates/bevy_render/src/render_graph

1 file changed

+9
-4
lines changed

crates/bevy_render/src/render_graph/app.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,24 @@ impl RenderGraphApp for App {
2828
node_name: &'static str,
2929
) -> &mut Self {
3030
let node = T::from_world(&mut self.world);
31-
let mut render_graph = self.world.resource_mut::<RenderGraph>();
31+
let mut render_graph = self.world.get_resource_mut::<RenderGraph>().expect(
32+
"RenderGraph not found. Make sure you are using add_render_graph_node on the RenderApp",
33+
);
3234

33-
let graph = render_graph.get_sub_graph_mut(sub_graph_name).unwrap();
35+
let graph = render_graph.sub_graph_mut(sub_graph_name);
3436
graph.add_node(node_name, node);
3537
self
3638
}
39+
3740
fn add_render_graph_edges(
3841
&mut self,
3942
sub_graph_name: &'static str,
4043
edges: &[&'static str],
4144
) -> &mut Self {
42-
let mut render_graph = self.world.resource_mut::<RenderGraph>();
43-
let graph = render_graph.get_sub_graph_mut(sub_graph_name).unwrap();
45+
let mut render_graph = self.world.get_resource_mut::<RenderGraph>().expect(
46+
"RenderGraph not found. Make sure you are using add_render_graph_node on the RenderApp",
47+
);
48+
let graph = render_graph.sub_graph_mut(sub_graph_name);
4449
graph.add_node_edges(edges);
4550
self
4651
}

0 commit comments

Comments
 (0)