ros_message/error.rs
1/// Enumeration of all errors that can be returned.
2#[derive(thiserror::Error, Debug)]
3pub enum Error {
4 /// Message doesn't have a valid format.
5 ///
6 /// Message names must follow the `package_name/MessageName` format.
7 ///
8 /// Packages must follow [REP 144](https://www.ros.org/reps/rep-0144.html) rules.
9 #[error("message path `{name}` is invalid, {reason}")]
10 InvalidMessagePath {
11 /// Full name of the message we are trying to parse.
12 name: String,
13 /// Reason for the failure.
14 reason: String,
15 },
16 /// Field in the `msg` or `srv` file has a name that doesn't fit any data type category.
17 #[error("data type `{name}` is invalid, {reason}")]
18 UnsupportedDataType {
19 /// Full name of the data type we are trying to parse.
20 name: String,
21 /// Reason for the failure.
22 reason: String,
23 },
24 /// The `msg` or `srv` file being parsed has invalid content.
25 #[error("bad content in message: `{0}`")]
26 BadMessageContent(String),
27 /// Certain operations on a `msg` or `srv` file require first handling all messages it depends upon.
28 ///
29 /// For example, to calculate an MD5 sum for a message, you first need to calculate it for
30 /// all messages it depends upon, and passing them into the calculation call.
31 #[error("message dependency missing: {package}/{name}")]
32 MessageDependencyMissing {
33 /// Package that the message is located in.
34 package: String,
35 /// Name of the missing message.
36 name: String,
37 },
38 /// Passed in constant value is not parsable as its data type.
39 #[error("bad constant value `{value}` of type {datatype} in field {name}")]
40 BadConstant {
41 /// Name of the constant.
42 name: String,
43 /// Type of the invalid value.
44 datatype: String,
45 /// The invalid value provided.
46 value: String,
47 },
48}
49
50/// Convenience type for shorter return value syntax of this crate's errors.
51pub type Result<T> = std::result::Result<T, Error>;