Skip to content

Commit 166279e

Browse files
add some info from ReflectPathError to the error messages (#5626)
# Objective - The `Display` impl for `ReflectPathError` is pretty unspecific (e.g. `the current struct doesn't have a field with the given name` - it has info for better messages available ## Solution - make the display impl more descriptive by including values from the type
1 parent fe97b38 commit 166279e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/bevy_reflect/src/path.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ use thiserror::Error;
66
/// An error returned from a failed path string query.
77
#[derive(Debug, PartialEq, Eq, Error)]
88
pub enum ReflectPathError<'a> {
9-
#[error("expected an identifier at the given index")]
9+
#[error("expected an identifier at index {index}")]
1010
ExpectedIdent { index: usize },
11-
#[error("the current struct doesn't have a field with the given name")]
11+
#[error("the current struct doesn't have a field with the name `{field}`")]
1212
InvalidField { index: usize, field: &'a str },
13-
#[error("the current tuple struct doesn't have a field with the given index")]
13+
#[error("the current tuple struct doesn't have a field with the index {tuple_struct_index}")]
1414
InvalidTupleStructIndex {
1515
index: usize,
1616
tuple_struct_index: usize,
1717
},
18-
#[error("the current list doesn't have a value at the given index")]
18+
#[error("the current list doesn't have a value at the index {list_index}")]
1919
InvalidListIndex { index: usize, list_index: usize },
20-
#[error("encountered an unexpected token")]
20+
#[error("encountered an unexpected token `{token}`")]
2121
UnexpectedToken { index: usize, token: &'a str },
22-
#[error("expected a token, but it wasn't there.")]
22+
#[error("expected token `{token}`, but it wasn't there.")]
2323
ExpectedToken { index: usize, token: &'a str },
2424
#[error("expected a struct, but found a different reflect value")]
2525
ExpectedStruct { index: usize },

0 commit comments

Comments
 (0)