cat_dev/mion/proto/parameter/
errors.rs

1//! Errors related to MION Parameter Space Port.
2
3use miette::Diagnostic;
4use thiserror::Error;
5
6#[derive(Error, Diagnostic, Debug, PartialEq, Eq)]
7pub enum MionParameterAPIError {
8	/// You passed a parameter space to an API that requires the full parameter
9	/// space, but it was not the correct length (512 bytes).
10	#[error(
11		"The MION Parameter body you passed in was: {0} bytes long, but must be exactly 512 bytes long!"
12	)]
13	#[diagnostic(code(cat_dev::api::mion::parameter::body_incorrect_length))]
14	BodyNotCorrectLength(usize),
15	/// You tried asking for a parameter of a specific name, but we could not
16	/// find a parameter with the name you specified.
17	///
18	/// We have created the concept of "name"'s for some parameters in the
19	/// parameter space. Although the official CLI tools just used indexes, I
20	/// in particular find indexes hard to remember so wanted to ensure folks
21	/// could just "say" what they wanted to lookup. Of course though not every
22	/// field is named, nor does it mean the API was given a non typo'd value.
23	#[error("The MION Parameter name: {0} is not known, cannot find index.")]
24	#[diagnostic(code(cat_dev::api::mion::parameter::name_not_known))]
25	NameNotKnown(String),
26	/// You tried asking for a parameter that does not exist.
27	///
28	/// There are only 512 parameters, so you can only ask for parameters in
29	/// (0-511) inclusive.
30	#[error(
31		"You asked for the MION Parameter at index: {0}, but MION Parameter indexes cannot be greater than 511."
32	)]
33	#[diagnostic(code(cat_dev::api::mion::parameter::not_in_range))]
34	NotInRange(usize),
35}
36
37#[derive(Error, Diagnostic, Debug, PartialEq, Eq)]
38pub enum MionParamProtocolError {
39	/// We got an error code back from trying to interact with the MION
40	/// paramspace port.
41	///
42	/// We unfortunately do not have these error codes known at this point in
43	/// time.
44	#[error("Error code received from MION Params: `{0}`")]
45	#[diagnostic(code(cat_dev::net::parse::mion::params::error_code))]
46	ErrorCode(i32),
47	/// Unknown packet type for the MION Params port.
48	#[error(
49		"Unknown Packet Type: `{0}` received from the network (this may mean your CAT-DEV is doing something we didn't expect)"
50	)]
51	#[diagnostic(code(cat_dev::net::parse::mion::params::unknown_packet_type))]
52	PacketType(i32),
53}