use std::path::PathBuf;
use thiserror::Error;
use crate::ParamKind;
use crate::pixel::{LayerError, PixelDepthKind};
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum AexloError {
#[error("Failed to load plugin {}: {source}", path.display())]
PluginLoad {
path: PathBuf,
#[source]
source: Box<dyn std::error::Error + Send + Sync>,
},
#[error("Plugin not found: {}", path.display())]
PluginNotFound {
path: PathBuf,
},
#[error("Ambiguous plugin bundle {}: expected exactly one executable in Contents/MacOS", path.display())]
AmbiguousBundle {
path: PathBuf,
},
#[error("Plugin container is not loaded.")]
PluginNotLoaded,
#[error("Plugin rejected {command} with error code: {code}")]
PluginExecutionFailed {
command: String,
code: i64,
},
#[error("App host is already fixed; call Host::install once, before Host::get")]
AppHostAlreadySet,
#[error("Parameter index {index} out of bounds (max {max})")]
ParamIndexOutOfBounds {
index: usize,
max: usize,
},
#[error("Parameter {index} type mismatch: expected {expected:?}, got {actual:?}")]
ParamTypeMismatch {
index: usize,
expected: ParamKind,
actual: ParamKind,
},
#[error("The plugin declared this frame not renderable on the GPU")]
GpuRenderDeclined,
#[error("No GPU device available for GPU render")]
GpuUnavailable,
#[error("GPU error: {0}")]
Gpu(String),
#[error("Invalid size {width}x{height}: dimensions must be positive and fit in i32")]
InvalidSize {
width: u32,
height: u32,
},
#[error("Layer error: {0}")]
Layer(#[from] LayerError),
#[error("Requested a {requested} layer, but it is {actual}")]
DepthMismatch {
requested: PixelDepthKind,
actual: PixelDepthKind,
},
}
impl AexloError {
pub fn is_cancelled(&self) -> bool {
matches!(self, AexloError::PluginExecutionFailed { code, .. }
if *code == after_effects_sys::PF_Interrupt_CANCEL as i64)
}
}
pub type Result<T> = std::result::Result<T, AexloError>;