]>
code.octet-stream.net Git - m17rt/blob - m17app/src/error.rs
1 use std
::{fmt
::Display
, path
::PathBuf
};
5 /// Errors originating from the M17 Rust Toolkit core
6 #[derive(Debug, Error)]
8 #[error("given callsign contains at least one character invalid in M17: {0}")]
9 InvalidCallsignCharacters(char),
11 #[error("given callsign is {0} characters long; maximum is 9")]
12 CallsignTooLong(usize),
14 #[error("error during soundcard initialisation")]
17 #[error("unable to locate sound card '{0}' - is it in use?")]
18 SoundcardNotFound(String
),
20 #[error("unable to set up RTL-SDR receiver")]
24 "provided packet payload is too large: provided {provided} bytes, capacity {capacity}"
26 PacketTooLarge
{ provided
: usize, capacity
: usize },
28 #[error("provided path to RRC file could not be opened: {0}")]
29 InvalidRrcPath(PathBuf
),
31 #[error("failed to read from RRC file: {0}")]
32 RrcReadFailed(PathBuf
),
34 #[error("tried to start app more than once")]
37 #[error("tried to close app that is not started")]
40 #[error("adapter error for id {0}: {1}")]
41 Adapter(usize, #[source] AdapterError),
44 pub type AdapterError
= Box
<dyn std
::error
::Error
+ Sync
+ Send
+ '
static>;
46 /// Iterator over potentially multiple errors
47 #[derive(Debug, Error)]
48 pub struct M17Errors(pub(crate) Vec
<M17Error
>);
49 impl Iterator
for M17Errors
{
52 fn next(&mut self) -> Option
<Self::Item
> {
57 impl Display
for M17Errors
{
58 fn fmt(&self, f
: &mut std
::fmt
::Formatter
<'_
>) -> std
::fmt
::Result
{
59 write
!(f
, "{:?}", self.0)