]>
code.octet-stream.net Git - m17rt/blob - m17app/src/error.rs
1 use std
::{fmt
::Display
, path
::PathBuf
};
5 /// Errors from the M17 Rust Toolkit
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),
43 #[error("soundmodem component error: {0}")]
44 Soundmodem(#[source] SoundmodemError),
47 /// Arbitrary error type returned from adapters, which may be user-implemented
48 pub type AdapterError
= Box
<dyn std
::error
::Error
+ Sync
+ Send
+ '
static>;
50 /// Arbitrary error type returned from soundmodem components, which may be user-implemented
51 pub type SoundmodemError
= Box
<dyn std
::error
::Error
+ Sync
+ Send
+ '
static>;
53 /// Iterator over potentially multiple errors
54 #[derive(Debug, Error)]
55 pub struct M17Errors(pub(crate) Vec
<M17Error
>);
56 impl Iterator
for M17Errors
{
59 fn next(&mut self) -> Option
<Self::Item
> {
64 impl Display
for M17Errors
{
65 fn fmt(&self, f
: &mut std
::fmt
::Formatter
<'_
>) -> std
::fmt
::Result
{
66 let mut displays
= vec
![];
68 displays
.push(e
.to_string());
70 write
!(f
, "[{}]", displays
.join(", "))
74 #[derive(Debug, Error)]
75 pub enum M17SoundmodemError
{}