mesh_tools/
error.rs

1//! # Error Handling
2//!
3//! This module defines the error types and result wrappers used throughout the library.
4//! It centralizes error handling to provide consistent and meaningful error messages
5//! for various failure scenarios that might occur during glTF creation and export.
6//!
7//! The `GltfError` enum covers errors from various sources including:
8//! - I/O operations
9//! - JSON serialization/deserialization
10//! - Invalid data or parameters
11//! - Texture processing issues
12//!
13//! The module also provides a convenient `Result` type alias for functions
14//! that may return a `GltfError`.
15
16use std::io;
17use thiserror::Error;
18use crate::texture;
19
20/// Comprehensive error type for glTF export operations
21#[derive(Error, Debug)]
22pub enum GltfError {
23    #[error("IO error: {0}")]
24    Io(#[from] io::Error),
25    
26    #[error("JSON serialization error: {0}")]
27    Json(#[from] serde_json::Error),
28    
29    #[error("Invalid data: {0}")]
30    InvalidData(String),
31    
32    #[error("Invalid index")]
33    InvalidIndex,
34    
35    #[error("Texture error: {0:?}")]
36    Texture(#[from] texture::TextureError),
37}
38
39/// Result type for glTF export operations
40pub type Result<T> = std::result::Result<T, GltfError>;