1use std::{
2 error::Error,
3 fmt::{Display, Formatter},
4};
5
6#[derive(Debug)]
8pub enum PlaySoundError<E> {
9 SoundLimitReached,
11 IntoSoundError(E),
13}
14
15impl<E> Display for PlaySoundError<E> {
16 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
17 match self {
18 PlaySoundError::SoundLimitReached => f.write_str(
19 "Could not play a sound because the maximum number of sounds has been reached.",
20 ),
21 PlaySoundError::IntoSoundError(_) => {
22 f.write_str("An error occurred when initializing the sound.")
23 }
24 }
25 }
26}
27
28impl<E: std::fmt::Debug> Error for PlaySoundError<E> {}
29
30#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
35pub struct ResourceLimitReached;
36
37impl Display for ResourceLimitReached {
38 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
39 f.write_str(
40 "Could not add a resource because the maximum capacity for that resource has been reached",
41 )
42 }
43}
44
45impl Error for ResourceLimitReached {}