pub enum SubXError {
Show 20 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),
OutputModeUnsupported {
command: 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_core::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 a stable process exit code (1–6). That
mapping is a property of running the subx-cli binary and lives in
that binary’s SubXErrorExt::exit_code extension trait (rendered
terminal prose likewise); this enum itself carries only the machine-readable
contract — Self::category, Self::machine_code and Self::hint
— which library consumers can call without importing anything.
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.
OutputModeUnsupported
The active output mode (e.g. --output json) is incompatible
with the requested subcommand.
Currently emitted by generate-completion, whose stdout is by
design a shell-completion script and cannot be wrapped in the
JSON envelope contract.
Only the subx-cli binary ever constructs this variant — no code
under src/core/ or src/services/ produces it. It nevertheless
stays in the core enum so category() and machine_code() keep
their wildcard-free exhaustive matches (a new variant must be
mapped, not absorbed by a catch-all). The deliberate asymmetry
below — category() is the generic "command_execution" while
machine_code() is the more specific
"E_OUTPUT_MODE_UNSUPPORTED" — is spec-locked.
Other(Error)
Catch-all error variant wrapping any other failure.
Implementations§
Source§impl SubXError
impl SubXError
Sourcepub fn config<S>(message: S) -> SubXError
pub fn config<S>(message: S) -> SubXError
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) -> SubXError
pub fn subtitle_format<S1, S2>(format: S1, message: S2) -> SubXError
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>(message: S) -> SubXError
pub fn audio_processing<S>(message: S) -> SubXError
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>(message: S) -> SubXError
pub fn ai_service<S>(message: S) -> SubXError
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>(message: S) -> SubXError
pub fn file_matching<S>(message: S) -> SubXError
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) -> SubXError
pub fn parallel_processing(msg: String) -> SubXError
Create a parallel processing error with the given message.
Sourcepub fn task_execution_failed(task_id: String, reason: String) -> SubXError
pub fn task_execution_failed(task_id: String, reason: String) -> SubXError
Create a task execution failure error with task ID and reason.
Sourcepub fn worker_pool_exhausted() -> SubXError
pub fn worker_pool_exhausted() -> SubXError
Create a worker pool exhausted error.
Sourcepub fn task_timeout(task_id: String, duration: Duration) -> SubXError
pub fn task_timeout(task_id: String, duration: Duration) -> SubXError
Create a task timeout error with task ID and duration.
Sourcepub fn dialogue_detection_failed<S>(msg: S) -> SubXError
pub fn dialogue_detection_failed<S>(msg: S) -> SubXError
Create a dialogue detection failure error with the given message.
Sourcepub fn invalid_audio_format<S>(format: S) -> SubXError
pub fn invalid_audio_format<S>(format: S) -> SubXError
Create an invalid audio format error for the given format.
Sourcepub fn dialogue_segment_invalid<S>(reason: S) -> SubXError
pub fn dialogue_segment_invalid<S>(reason: S) -> SubXError
Create an invalid dialogue segment error with the given reason.
Sourcepub fn category(&self) -> &'static str
pub fn category(&self) -> &'static str
Stable snake_case machine-readable category for the JSON error envelope. The mapping is closed and exhaustive (no wildcard arm) so the compiler enforces updates whenever a new variant is added.
This mapping is locked by the error-handling capability spec.
Sourcepub fn machine_code(&self) -> &'static str
pub fn machine_code(&self) -> &'static str
Stable upper-snake-case machine code prefixed with E_.
Mirrors Self::category one-to-one and is similarly closed
against the addition of new variants.
Sourcepub fn hint(&self) -> Option<&'static str>
pub fn hint(&self) -> Option<&'static str>
Short user-facing remediation hint, or None when none applies.
This is a separate, structured surface from the prose hints
already baked into the binary’s SubXErrorExt::user_friendly_message
(src/cli/error_ext.rs); JSON callers receive it under
error.hint.
The returned text is written for the subx-cli terminal and names
its binary and flags. Library consumers SHALL treat the return
value as an availability signal — branch on Some/None and
render their own localized copy — rather than as display copy.
Rewriting the prose is not a breaking change; changing which
variants return Some is: that set is the stable part of the
contract.
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
use the Display impl or to_string()
Source§impl From<ConfigError> for SubXError
impl From<ConfigError> for SubXError
Source§fn from(err: ConfigError) -> SubXError
fn from(err: ConfigError) -> SubXError
Auto Trait Implementations§
impl !RefUnwindSafe for SubXError
impl !UnwindSafe for SubXError
impl Freeze for SubXError
impl Send for SubXError
impl Sync for SubXError
impl Unpin for SubXError
impl UnsafeUnpin 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.