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