Skip to main content

crispy_m3u/
error.rs

1//! Error types for M3U parsing and writing.
2
3use thiserror::Error;
4
5/// Errors that can occur during M3U parsing or writing.
6#[derive(Debug, Error)]
7pub enum M3uError {
8    /// The input is not a valid M3U playlist (missing `#EXTM3U` header).
9    #[error("invalid M3U: missing #EXTM3U header")]
10    MissingHeader,
11
12    /// A parse error at a specific line.
13    #[error("parse error at line {line}: {message}")]
14    Parse {
15        /// 1-based line number where the error occurred.
16        line: usize,
17        /// Human-readable description of the error.
18        message: String,
19    },
20
21    /// An I/O error (e.g. reading from a file).
22    #[error("io error: {0}")]
23    Io(#[from] std::io::Error),
24}