lowfi/src/error.rs
Tal 02a4e688bd chore: update dependencies
for some reason, rodio decided it would be a great idea to change all of
the core terminology to be less technical. this is frankly strange, but
it's best not to use an outdated version of the dependency.

rodio is for some reason switching to a "breaking change every single
update" versioning model. why? i have frankly no idea, semver exists for
a reason and they decided just not to use it. 0.x.x is stupid, and
people should realize semver exists for a reason. to the total of zero
people who will read this, thanks for reading my short rant.
2026-03-05 20:34:45 +01:00

62 lines
1.8 KiB
Rust

//! Application-wide error type.
//!
//! This module exposes a single `Error` enum that aggregates the common
//! error kinds used across the application (IO, networking, UI, audio,
//! persistence). Higher-level functions should generally return
//! `crate::error::Result<T>` to make error handling consistent.
use crate::{bookmark, tracks, ui, volume};
use tokio::sync::{broadcast, mpsc};
/// Result alias using the crate-wide `Error` type.
pub type Result<T> = std::result::Result<T, Error>;
/// Central application error.
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("unable to load/save the persistent volume")]
PersistentVolume(#[from] volume::Error),
#[error("unable to load/save bookmarks")]
Bookmarks(#[from] bookmark::Error),
#[error("unable to fetch data")]
Request(#[from] reqwest::Error),
#[error("C string null error")]
FfiNull(#[from] std::ffi::NulError),
#[error("error interfacing with audio")]
Rodio(#[from] rodio::DeviceSinkError),
#[error("couldn't send internal message")]
Send(#[from] mpsc::error::SendError<crate::Message>),
#[error("couldn't add track to the queue")]
Queue(#[from] mpsc::error::SendError<tracks::Queued>),
#[error("couldn't update UI state")]
Broadcast(#[from] broadcast::error::SendError<ui::Update>),
#[error("io error")]
Io(#[from] std::io::Error),
#[error("directory not found")]
Directory,
#[error("couldn't fetch track from downloader")]
Download,
#[error("couldn't parse integer")]
Parse(#[from] std::num::ParseIntError),
#[error("track failure")]
Track(#[from] tracks::Error),
#[error("ui failure")]
UI(#[from] ui::Error),
#[error("join error")]
JoinError(#[from] tokio::task::JoinError),
}