Skip to content

Commit

Permalink
Minor error message macro tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser committed Aug 25, 2024
1 parent 4e5240d commit 9e36919
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ macro_rules! ascom_error_codes {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
$(
Self::$name => write!(f, "{}", stringify!($name)),
Self::$name => f.write_str(stringify!($name)),
)*
_ => match self.as_driver_error() {
Ok(driver_code) => write!(f, "DRIVER_ERROR[{driver_code}]"),
Expand All @@ -151,11 +151,14 @@ macro_rules! ascom_error_codes {
#[doc = $doc]
pub const $name: Self = Self {
code: ASCOMErrorCode::$name,
message: Cow::Borrowed($doc),
message: Cow::Borrowed(ascom_error_codes!(@msg $name $doc)),
};
)*
}
};

(@msg OK $doc:literal) => ("");
(@msg $name:ident $doc:literal) => ($doc);
}

ascom_error_codes! {
Expand Down

0 comments on commit 9e36919

Please sign in to comment.