Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/crates/bevy_reflect/src/func/args/error.rs
6600 views
1
use alloc::borrow::Cow;
2
3
use thiserror::Error;
4
5
use crate::func::args::Ownership;
6
7
/// An error that occurs when converting an [argument].
8
///
9
/// [argument]: crate::func::args::Arg
10
#[derive(Debug, Error, PartialEq)]
11
pub enum ArgError {
12
/// The argument is not the expected type.
13
#[error("expected `{expected}` but received `{received}` (@ argument index {index})")]
14
UnexpectedType {
15
/// Argument index.
16
index: usize,
17
/// Expected argument type path.
18
expected: Cow<'static, str>,
19
/// Received argument type path.
20
received: Cow<'static, str>,
21
},
22
/// The argument has the wrong ownership.
23
#[error("expected {expected} value but received {received} value (@ argument index {index})")]
24
InvalidOwnership {
25
/// Argument index.
26
index: usize,
27
/// Expected ownership.
28
expected: Ownership,
29
/// Received ownership.
30
received: Ownership,
31
},
32
/// Occurs when attempting to access an argument from an empty [`ArgList`].
33
///
34
/// [`ArgList`]: crate::func::args::ArgList
35
#[error("expected an argument but received none")]
36
EmptyArgList,
37
}
38
39
/// The given argument count is out of bounds.
40
#[derive(Debug, Error, PartialEq)]
41
#[error("argument count out of bounds: {0}")]
42
pub struct ArgCountOutOfBoundsError(pub usize);
43
44