Skip to main content

vst3_host/
error.rs

1//! Error types for the vst3-host library
2
3use thiserror::Error;
4
5/// Main error type for vst3-host operations.
6///
7/// Marked `#[non_exhaustive]`: match with a wildcard arm, as new variants may be added in
8/// future versions without it being a breaking change.
9#[derive(Error, Debug)]
10#[non_exhaustive]
11pub enum Error {
12    /// Plugin file not found
13    #[error("Plugin not found: {0}")]
14    PluginNotFound(String),
15
16    /// Failed to load plugin
17    #[error("Failed to load plugin: {0}")]
18    PluginLoadFailed(String),
19
20    /// Plugin crashed during operation
21    #[error("Plugin crashed")]
22    PluginCrashed,
23
24    /// Plugin operation timed out
25    #[error("Plugin operation timed out")]
26    PluginTimeout,
27
28    /// Invalid parameter
29    #[error("Invalid parameter: {0}")]
30    InvalidParameter(String),
31
32    /// Audio backend error
33    #[error("Audio backend error: {0}")]
34    AudioBackendError(String),
35
36    /// MIDI error
37    #[error("MIDI error: {0}")]
38    MidiError(String),
39
40    /// COM/VST3 interface error
41    #[error("VST3 interface error: {0}")]
42    InterfaceError(String),
43
44    /// Process isolation error
45    #[error("Process isolation error: {0}")]
46    ProcessError(String),
47
48    /// IO error
49    #[error(transparent)]
50    IoError(#[from] std::io::Error),
51
52    /// The plugin's `process()` returned a failure code. Carries the raw tresult rather than a
53    /// formatted `String` so returning it from the audio callback allocates nothing.
54    #[error("Plugin process() failed: {0:#x}")]
55    ProcessFailed(i32),
56
57    /// The plugin is not currently active/processing. A unit variant for the same reason as
58    /// [`Self::ProcessFailed`] — this is rejected on the audio path once per block while stopped.
59    #[error("Plugin is not processing")]
60    NotProcessing,
61
62    /// Other errors
63    #[error("{0}")]
64    Other(String),
65}
66
67/// Convenient Result type alias
68pub type Result<T> = std::result::Result<T, Error>;