vc-runtime 0.1.0

Runtime backend for Visual Compiler
Documentation
//! Error types for ComfyUI service layer.

use thiserror::Error;

#[derive(Debug, Error)]
pub enum WorkflowError {
    #[error("Failed to parse workflow JSON: {0}")]
    Parse(#[from] serde_json::Error),

    #[error("Unsupported workflow metadata version {version} (supported: {supported:?})")]
    UnsupportedVersion { version: u32, supported: Vec<u32> },

    #[error("Missing required binding: {key}")]
    MissingBinding { key: String },

    #[error("Node {node} not found in workflow")]
    MissingNode { node: String },

    #[error("Node {node} does not have input {input}")]
    MissingInput { node: String, input: String },

    #[error("Node {node} does not have output {output}")]
    MissingOutput { node: String, output: String },

    #[error("Validation failed: {reason}")]
    Validation { reason: String },

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),
}

#[derive(Debug, Error)]
pub enum ComfyApiError {
    #[error("HTTP request failed: {0}")]
    Http(#[from] reqwest::Error),

    #[error("ComfyUI returned error: {status} - {body}")]
    Api { status: reqwest::StatusCode, body: String },

    #[error("Polling timeout after {duration_secs} seconds")]
    Timeout { duration_secs: u64 },

    #[error("Failed to download image: {0}")]
    Download(String),

    #[error("Invalid URL: {0}")]
    InvalidUrl(#[from] url::ParseError),
}