Skip to content

Commit 859d9c4

Browse files
bevy_render: improve panic message when render graph node doesn't exist (#21321)
# Objective It should be possible to enable minimal bevy features by disabling all and then progressively enabling them until everything works. This however requires, that bevy has good error reporting and gracefully supports different featuresets. I ran my code with minimal features and got this unhelpful error: ``` thread 'main' (993068) panicked at /home/jakob/dev/rust/bevy/crates/bevy_render/src/render_graph/graph.rs:158:26: InvalidNode(PostProcessing) ``` ## Solution With this PR it looks like this: ``` thread 'main' (989393) panicked at /home/jakob/dev/rust/bevy/crates/bevy_pbr/src/wireframe.rs:136:14: node PostProcessing does not exist ``` Which immediately helps me figure out that I need some feature for the `WireframePlugin` I added. Co-authored-by: Alice Cecile <[email protected]>
1 parent efb8e1d commit 859d9c4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

crates/bevy_render/src/render_graph/app.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ impl RenderGraphExt for World {
5353
self
5454
}
5555

56+
#[track_caller]
5657
fn add_render_graph_edges<const N: usize>(
5758
&mut self,
5859
sub_graph: impl RenderSubGraph,
@@ -121,6 +122,7 @@ impl RenderGraphExt for SubApp {
121122
self
122123
}
123124

125+
#[track_caller]
124126
fn add_render_graph_edges<const N: usize>(
125127
&mut self,
126128
sub_graph: impl RenderSubGraph,

crates/bevy_render/src/render_graph/graph.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ impl RenderGraph {
145145
///
146146
/// Defining an edge that already exists is not considered an error with this api.
147147
/// It simply won't create a new edge.
148+
#[track_caller]
148149
pub fn add_node_edges<const N: usize>(&mut self, edges: impl IntoRenderNodeArray<N>) {
149150
for window in edges.into_array().windows(2) {
150151
let [a, b] = window else {
@@ -155,7 +156,7 @@ impl RenderGraph {
155156
// Already existing edges are very easy to produce with this api
156157
// and shouldn't cause a panic
157158
RenderGraphError::EdgeAlreadyExists(_) => {}
158-
_ => panic!("{err:?}"),
159+
_ => panic!("{err}"),
159160
}
160161
}
161162
}

0 commit comments

Comments
 (0)