game_toolkit_dosaudio/
error.rs1use core::fmt;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
5#[non_exhaustive]
6pub enum Error {
7 Config(&'static str),
9 BackwardsTime,
11 QueueFull,
13 IrqQueueFull,
15 CaptureOverflow,
17 Format(&'static str),
19 TooLarge,
21}
22
23impl fmt::Display for Error {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 match self {
26 Self::Config(reason) | Self::Format(reason) => f.write_str(reason),
27 Self::BackwardsTime => f.write_str("machine time cannot move backwards"),
28 Self::QueueFull => {
29 f.write_str("sound command queue is full; render audio before retrying")
30 }
31 Self::IrqQueueFull => {
32 f.write_str("DMA completion queue is full; poll completion events before retrying")
33 }
34 Self::CaptureOverflow => f.write_str(
35 "synthesis capture overflowed; drain it more often or increase capacity",
36 ),
37 Self::TooLarge => f.write_str("time or file size exceeds the supported range"),
38 }
39 }
40}
41
42impl std::error::Error for Error {}
43
44pub type Result<T> = core::result::Result<T, Error>;