Enum SubXError

Source
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.

Fields

§message: String

Description of the configuration error

§

SubtitleFormat

Subtitle format error indicating invalid timestamps or structure.

Provides the subtitle format and detailed message.

Fields

§format: String

The subtitle format that caused the error (e.g., “SRT”, “ASS”)

§message: String

Detailed error message describing the issue

§

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.

Fields

§message: String

Error message from the API

§source: ApiErrorSource

Source of the API error

§

AudioProcessing

Audio processing error during analysis or format conversion.

Provides a message describing the audio processing failure.

Fields

§message: String

Description of the audio processing error

§

FileMatching

Error during file matching or discovery.

Contains details about path resolution or pattern matching failures.

Fields

§message: String

Description of the file matching error

§

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

§path: PathBuf

The directory path that could not be read

§source: Error

The underlying I/O error

§

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

Source

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");
Source

pub fn subtitle_format<S1, S2>(format: S1, message: S2) -> Self
where S1: Into<String>, S2: Into<String>,

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"));
Source

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");
Source

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");
Source

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");
Source

pub fn parallel_processing(msg: String) -> Self

Create a parallel processing error with the given message.

Source

pub fn task_execution_failed(task_id: String, reason: String) -> Self

Create a task execution failure error with task ID and reason.

Source

pub fn worker_pool_exhausted() -> Self

Create a worker pool exhausted error.

Source

pub fn task_timeout(task_id: String, duration: Duration) -> Self

Create a task timeout error with task ID and duration.

Source

pub fn dialogue_detection_failed<S: Into<String>>(msg: S) -> Self

Create a dialogue detection failure error with the given message.

Source

pub fn invalid_audio_format<S: Into<String>>(format: S) -> Self

Create an invalid audio format error for the given format.

Source

pub fn dialogue_segment_invalid<S: Into<String>>(reason: S) -> Self

Create an invalid dialogue segment error with the given reason.

Source

pub fn exit_code(&self) -> i32

Return the corresponding exit code for this error variant.

§Examples
assert_eq!(SubXError::config("x").exit_code(), 2);
Source

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:"));
Source§

impl SubXError

Helper functions for Whisper API and audio processing related errors.

Source

pub fn whisper_api<T: Into<String>>(message: T) -> Self

Create a Whisper API error.

§Arguments
  • message - The error message describing the Whisper API failure
§Returns

A new SubXError::Api variant with Whisper as the source

Source

pub fn audio_extraction<T: Into<String>>(message: T) -> Self

Create an audio extraction/transcoding error.

§Arguments
  • message - The error message describing the audio processing failure
§Returns

A new SubXError::AudioProcessing variant

Trait Implementations§

Source§

impl Debug for SubXError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SubXError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for SubXError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Box<dyn Error>> for SubXError

Source§

fn from(err: Box<dyn Error>) -> Self

Converts to this type from the input type.
Source§

impl From<ConfigError> for SubXError

Source§

fn from(err: ConfigError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SubXError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SubXError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SubXError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SubXError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SubXError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for SubXError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,