Skip to content

Commit b8ed0a8

Browse files
committed
Make FunctionError variants sound more error-y
1 parent 4088843 commit b8ed0a8

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

crates/bevy_reflect/src/func/args/info.rs

+2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ impl ArgInfo {
8383
}
8484

8585
/// A representation of an argument.
86+
///
87+
/// This is primarily used for error reporting and debugging.
8688
#[derive(Debug, Clone, PartialEq, Eq)]
8789
pub enum ArgId {
8890
/// The index of the argument within its function.

crates/bevy_reflect/src/func/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use thiserror::Error;
88
pub enum FunctionError {
99
/// An error occurred while converting an argument.
1010
#[error(transparent)]
11-
Arg(#[from] ArgError),
11+
ArgError(#[from] ArgError),
1212
/// The number of arguments provided does not match the expected number.
1313
#[error("expected {expected} arguments but received {received}")]
14-
ArgCount { expected: usize, received: usize },
14+
InvalidArgCount { expected: usize, received: usize },
1515
}

crates/bevy_reflect/src/func/into_function.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ macro_rules! impl_into_function {
137137

138138
$crate::func::DynamicFunction::new(move |args, _info| {
139139
if args.len() != COUNT {
140-
return Err($crate::func::error::FunctionError::ArgCount {
140+
return Err($crate::func::error::FunctionError::InvalidArgCount {
141141
expected: COUNT,
142142
received: args.len(),
143143
});
@@ -186,7 +186,7 @@ macro_rules! impl_into_function {
186186

187187
$crate::func::DynamicFunction::new(move |args, _info| {
188188
if args.len() != COUNT {
189-
return Err($crate::func::error::FunctionError::ArgCount {
189+
return Err($crate::func::error::FunctionError::InvalidArgCount {
190190
expected: COUNT,
191191
received: args.len(),
192192
});
@@ -237,7 +237,7 @@ macro_rules! impl_into_function {
237237

238238
$crate::func::DynamicFunction::new(move |args, _info| {
239239
if args.len() != COUNT {
240-
return Err($crate::func::error::FunctionError::ArgCount {
240+
return Err($crate::func::error::FunctionError::InvalidArgCount {
241241
expected: COUNT,
242242
received: args.len(),
243243
});
@@ -288,7 +288,7 @@ macro_rules! impl_into_function {
288288

289289
$crate::func::DynamicFunction::new(move |args, _info| {
290290
if args.len() != COUNT {
291-
return Err($crate::func::error::FunctionError::ArgCount {
291+
return Err($crate::func::error::FunctionError::InvalidArgCount {
292292
expected: COUNT,
293293
received: args.len(),
294294
});

crates/bevy_reflect/src/func/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ mod tests {
166166
let result = func.call(args);
167167
assert_eq!(
168168
result.unwrap_err(),
169-
FunctionError::ArgCount {
169+
FunctionError::InvalidArgCount {
170170
expected: 1,
171171
received: 0
172172
}
@@ -182,7 +182,7 @@ mod tests {
182182
let result = func.call(args);
183183
assert_eq!(
184184
result.unwrap_err(),
185-
FunctionError::ArgCount {
185+
FunctionError::InvalidArgCount {
186186
expected: 0,
187187
received: 1
188188
}
@@ -198,7 +198,7 @@ mod tests {
198198
let result = func.call(args);
199199
assert_eq!(
200200
result.unwrap_err(),
201-
FunctionError::Arg(ArgError::UnexpectedType {
201+
FunctionError::ArgError(ArgError::UnexpectedType {
202202
id: ArgId::Index(0),
203203
expected: Cow::Borrowed(i32::type_path()),
204204
received: Cow::Borrowed(u32::type_path())
@@ -215,7 +215,7 @@ mod tests {
215215
let result = func.call(args);
216216
assert_eq!(
217217
result.unwrap_err(),
218-
FunctionError::Arg(ArgError::InvalidOwnership {
218+
FunctionError::ArgError(ArgError::InvalidOwnership {
219219
id: ArgId::Index(0),
220220
expected: Ownership::Ref,
221221
received: Ownership::Owned

0 commit comments

Comments
 (0)