Skip to content

Commit

Permalink
Support to write error messages directly to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Dec 21, 2024
1 parent 4d982d4 commit 4c854db
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions firmware/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::json::{self, ToJson};
use crate::user::UserId;
use crate::{display, nfc, vereinsflieger};
use alloc::string::ToString;
use core::fmt;
use core::future::Future;
use embedded_io_async::Write;

/// Main error type
#[derive(Debug)]
Expand Down Expand Up @@ -126,3 +129,12 @@ impl fmt::Display for ErrorKind {
}
}
}

impl ToJson for ErrorKind {
async fn to_json<W: Write>(
&self,
json: &mut json::Writer<W>,
) -> Result<(), json::Error<W::Error>> {
json.write(self.to_string()).await
}
}

0 comments on commit 4c854db

Please sign in to comment.