pub enum SubXError {
Show 19 variants
Io(Error),
Config {
message: String,
},
SubtitleFormat {
format: String,
message: String,
},
AiService(String),
Api {
message: String,
source: ApiErrorSource,
},
AudioProcessing {
message: String,
},
FileMatching {
message: String,
},
FileAlreadyExists(String),
FileNotFound(String),
InvalidFileName(String),
FileOperationFailed(String),
CommandExecution(String),
NoInputSpecified,
InvalidPath(PathBuf),
PathNotFound(PathBuf),
DirectoryReadError {
path: PathBuf,
source: Error,
},
InvalidSyncConfiguration,
UnsupportedFileType(String),
Other(Error),
}
Expand description
Represents all possible errors in the SubX application.
Each variant provides specific context to facilitate debugging and user-friendly reporting.
§Examples
use subx_cli::error::{SubXError, SubXResult};
fn example() -> SubXResult<()> {
Err(SubXError::SubtitleFormat {
format: "SRT".to_string(),
message: "Invalid timestamp format".to_string(),
})
}
§Exit Codes
Each error variant maps to an exit code via SubXError::exit_code
.
Variants§
Io(Error)
I/O operation failed during file system access.
This variant wraps std::io::Error
and provides context about
file operations that failed.
§Common Causes
- Permission issues
- Insufficient disk space
- Network filesystem errors
Config
Configuration error due to invalid or missing settings.
Contains a human-readable message describing the issue.
SubtitleFormat
Subtitle format error indicating invalid timestamps or structure.
Provides the subtitle format and detailed message.
Fields
AiService(String)
AI service encountered an error.
Captures the raw error message from the AI provider.
Api
API request error with specified source.
Represents errors that occur during API requests, providing both the error message and the source of the API error.
AudioProcessing
Audio processing error during analysis or format conversion.
Provides a message describing the audio processing failure.
FileMatching
Error during file matching or discovery.
Contains details about path resolution or pattern matching failures.
FileAlreadyExists(String)
Indicates that a file operation failed because the target exists.
FileNotFound(String)
Indicates that the specified file was not found.
InvalidFileName(String)
Invalid file name encountered.
FileOperationFailed(String)
Generic file operation failure with message.
CommandExecution(String)
Generic command execution error.
NoInputSpecified
No input path was specified for the operation.
InvalidPath(PathBuf)
The provided path is invalid or malformed.
PathNotFound(PathBuf)
The specified path does not exist on the filesystem.
DirectoryReadError
Unable to read the specified directory.
Fields
InvalidSyncConfiguration
Invalid synchronization configuration: please specify video and subtitle files, or use -i parameter for batch processing.
UnsupportedFileType(String)
Unsupported file type encountered.
Other(Error)
Catch-all error variant wrapping any other failure.
Implementations§
Source§impl SubXError
impl SubXError
Sourcepub fn config<S: Into<String>>(message: S) -> Self
pub fn config<S: Into<String>>(message: S) -> Self
Create a configuration error with the given message.
§Examples
let err = SubXError::config("invalid setting");
assert_eq!(err.to_string(), "Configuration error: invalid setting");
Sourcepub fn subtitle_format<S1, S2>(format: S1, message: S2) -> Self
pub fn subtitle_format<S1, S2>(format: S1, message: S2) -> Self
Create a subtitle format error for the given format and message.
§Examples
let err = SubXError::subtitle_format("SRT", "invalid timestamp");
assert!(err.to_string().contains("SRT"));
Sourcepub fn audio_processing<S: Into<String>>(message: S) -> Self
pub fn audio_processing<S: Into<String>>(message: S) -> Self
Create an audio processing error with the given message.
§Examples
let err = SubXError::audio_processing("decode failed");
assert_eq!(err.to_string(), "Audio processing error: decode failed");
Sourcepub fn ai_service<S: Into<String>>(message: S) -> Self
pub fn ai_service<S: Into<String>>(message: S) -> Self
Create an AI service error with the given message.
§Examples
let err = SubXError::ai_service("network failure");
assert_eq!(err.to_string(), "AI service error: network failure");
Sourcepub fn file_matching<S: Into<String>>(message: S) -> Self
pub fn file_matching<S: Into<String>>(message: S) -> Self
Create a file matching error with the given message.
§Examples
let err = SubXError::file_matching("not found");
assert_eq!(err.to_string(), "File matching error: not found");
Sourcepub fn parallel_processing(msg: String) -> Self
pub fn parallel_processing(msg: String) -> Self
Create a parallel processing error with the given message.
Sourcepub fn task_execution_failed(task_id: String, reason: String) -> Self
pub fn task_execution_failed(task_id: String, reason: String) -> Self
Create a task execution failure error with task ID and reason.
Sourcepub fn worker_pool_exhausted() -> Self
pub fn worker_pool_exhausted() -> Self
Create a worker pool exhausted error.
Sourcepub fn task_timeout(task_id: String, duration: Duration) -> Self
pub fn task_timeout(task_id: String, duration: Duration) -> Self
Create a task timeout error with task ID and duration.
Sourcepub fn dialogue_detection_failed<S: Into<String>>(msg: S) -> Self
pub fn dialogue_detection_failed<S: Into<String>>(msg: S) -> Self
Create a dialogue detection failure error with the given message.
Sourcepub fn invalid_audio_format<S: Into<String>>(format: S) -> Self
pub fn invalid_audio_format<S: Into<String>>(format: S) -> Self
Create an invalid audio format error for the given format.
Sourcepub fn dialogue_segment_invalid<S: Into<String>>(reason: S) -> Self
pub fn dialogue_segment_invalid<S: Into<String>>(reason: S) -> Self
Create an invalid dialogue segment error with the given reason.
Sourcepub fn exit_code(&self) -> i32
pub fn exit_code(&self) -> i32
Return the corresponding exit code for this error variant.
§Examples
assert_eq!(SubXError::config("x").exit_code(), 2);
Sourcepub fn user_friendly_message(&self) -> String
pub fn user_friendly_message(&self) -> String
Return a user-friendly error message with suggested remedies.
§Examples
let msg = SubXError::config("missing key").user_friendly_message();
assert!(msg.contains("Configuration error:"));
Trait Implementations§
Source§impl Error for SubXError
impl Error for SubXError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ConfigError> for SubXError
impl From<ConfigError> for SubXError
Source§fn from(err: ConfigError) -> Self
fn from(err: ConfigError) -> Self
Auto Trait Implementations§
impl Freeze for SubXError
impl !RefUnwindSafe for SubXError
impl Send for SubXError
impl Sync for SubXError
impl Unpin for SubXError
impl !UnwindSafe for SubXError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.