Skip to main content

oximedia_packager/
error.rs

1//! Error types for the packager.
2
3use std::io;
4use thiserror::Error;
5
6/// Result type alias for packager operations.
7pub type PackagerResult<T> = Result<T, PackagerError>;
8
9/// Errors that can occur during packaging operations.
10#[derive(Debug, Error)]
11pub enum PackagerError {
12    /// I/O error occurred.
13    #[error("I/O error: {0}")]
14    Io(#[from] io::Error),
15
16    /// Invalid configuration parameter.
17    #[error("Invalid configuration: {0}")]
18    InvalidConfig(String),
19
20    /// Unsupported codec for packaging.
21    #[error("Unsupported codec: {0}")]
22    UnsupportedCodec(String),
23
24    /// Invalid bitrate ladder configuration.
25    #[error("Invalid bitrate ladder: {0}")]
26    InvalidLadder(String),
27
28    /// Segment generation failed.
29    #[error("Segment generation failed: {0}")]
30    SegmentFailed(String),
31
32    /// Manifest generation failed.
33    #[error("Manifest generation failed: {0}")]
34    ManifestFailed(String),
35
36    /// Encryption error.
37    #[error("Encryption error: {0}")]
38    EncryptionError(String),
39
40    /// Invalid media source.
41    #[error("Invalid media source: {0}")]
42    InvalidSource(String),
43
44    /// Missing required parameter.
45    #[error("Missing required parameter: {0}")]
46    MissingParameter(String),
47
48    /// Keyframe alignment failed.
49    #[error("Keyframe alignment failed: {0}")]
50    AlignmentFailed(String),
51
52    /// DRM preparation failed.
53    #[error("DRM preparation failed: {0}")]
54    DrmFailed(String),
55
56    /// Cloud upload failed.
57    #[error("Cloud upload failed: {0}")]
58    UploadFailed(String),
59
60    /// Generic packaging error.
61    #[error("Packaging error: {0}")]
62    PackagingError(String),
63
64    /// Core library error.
65    #[error("Core error: {0}")]
66    Core(#[from] oximedia_core::OxiError),
67
68    /// JSON serialization error.
69    #[error("JSON error: {0}")]
70    Json(#[from] serde_json::Error),
71
72    /// XML serialization error.
73    #[error("XML error: {0}")]
74    Xml(#[from] quick_xml::Error),
75
76    /// Time parsing error.
77    #[error("Time error: {0}")]
78    Time(String),
79}
80
81impl PackagerError {
82    /// Create an invalid configuration error.
83    pub fn invalid_config(msg: impl Into<String>) -> Self {
84        Self::InvalidConfig(msg.into())
85    }
86
87    /// Create an unsupported codec error.
88    pub fn unsupported_codec(msg: impl Into<String>) -> Self {
89        Self::UnsupportedCodec(msg.into())
90    }
91
92    /// Create a segment failed error.
93    pub fn segment_failed(msg: impl Into<String>) -> Self {
94        Self::SegmentFailed(msg.into())
95    }
96
97    /// Create a manifest failed error.
98    pub fn manifest_failed(msg: impl Into<String>) -> Self {
99        Self::ManifestFailed(msg.into())
100    }
101}