use std::io;
use std::path::PathBuf;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum BridgeError {
#[error("Python error: {0}")]
Python(String),
#[error("Failed to import module '{0}': {1}")]
Import(String, String),
#[error("Python venv not found or invalid at: {0}")]
VenvNotFound(PathBuf),
#[error("r2x-core is not installed in the Python environment")]
R2XCoreNotInstalled,
#[error("Failed to serialize/deserialize data: {0}")]
Serialization(String),
#[error("Failed to initialize Python interpreter: {0}")]
Initialization(String),
#[error("Plugin '{0}' not found")]
PluginNotFound(String),
#[error("Invalid entry point format: {0}")]
InvalidEntryPoint(String),
#[error("Invalid artifact bundle: {0}")]
InvalidArtifact(String),
#[error("Plugin stream error: {0}")]
Stream(String),
#[error("Artifact-mode invocation is unsupported: {0}")]
UnsupportedArtifactMode(String),
#[error("IO error: {0}")]
Io(#[from] io::Error),
}
impl From<pyo3::PyErr> for BridgeError {
fn from(err: pyo3::PyErr) -> Self {
BridgeError::Python(format!("{}", err))
}
}