avx-error

Crates.ioavx-error
lib.rsavx-error
version0.2.0
created_at2025-12-17 02:30:41.008057+00
updated_at2025-12-17 02:30:41.008057+00
descriptionAVL Platform error handling - replacement for anyhow/thiserror
homepagehttps://avila.inc
repositoryhttps://github.com/avilaops/arxis
max_upload_size
id1989188
size16,385
Nícolas Ávila (avilaops)

documentation

README

avx-error

Unified error handling system for the avx ecosystem.

Crates.io Documentation License

Features

Features

  • Zero Dependencies - Pure Rust (except derive macros)
  • Rich Error Context - Chain context information
  • Error Categories - 15+ predefined error kinds
  • Derive Macros - Automatic trait implementations
  • no_std Compatible - Works in embedded environments
  • Backtrace Support - Optional std backtrace integration
  • Type-Safe - Compile-time error handling

Error Kinds

  • InvalidInput - Bad input data
  • NotFound - Resource missing
  • PermissionDenied - Access denied
  • ConnectionFailed - Network error
  • Timeout - Operation timeout
  • DataCorruption - Corrupted data
  • ConfigError - Configuration issue
  • AuthenticationFailed - Auth failure
  • AuthorizationFailed - Permission failure
  • AlreadyExists - Duplicate resource
  • ResourceExhausted - Out of resources
  • Cancelled - Operation cancelled
  • Internal - Internal error
  • NotImplemented - Feature not implemented
  • Unavailable - Service unavailable
  • Unknown - Unknown error

Examples

Basic Usage

use avx_error::{Error, ErrorKind, Result};

fn load_config(path: &str) -> Result<Config> {
    if path.is_empty() {
        return Err(Error::new(
            ErrorKind::InvalidInput,
            "Path cannot be empty"
        ));
    }

    // ...
    Ok(Config::default())
}

Error Context

use avx_error::{Result, ResultExt};

fn parse_file(path: &str) -> Result<Data> {
    read_file(path)
        .context("Failed to read file")?;

    parse_json(contents)
        .with_context(|| format!("Failed to parse {}", path))?;

    Ok(data)
}

Custom Errors with Derive

use avx_error::Error as avxError;

#[derive(Debug, avxError)]
enum MyError {
    IoError(std::io::Error),
    ParseError(String),
    Custom { code: i32, message: String },
}

Error Matching

use avx_error::{Error, ErrorKind};

match error.kind() {
    ErrorKind::NotFound => {
        // Handle missing resource
    },
    ErrorKind::PermissionDenied => {
        // Handle access denied
    },
    _ => {
        // Handle other errors
    }
}

Installation

Add to your Cargo.toml:

[dependencies]
avx-error = "0.3.0"

With derive macros:

[dependencies]
avx-error = { version = "0.3.0", features = ["derive"] }

For no_std environments:

[dependencies]
avx-error = { version = "0.3.0", default-features = false }

Integration

All avx crates use avx-error as the foundation:

// In avx-db
pub type Result<T> = avx_error::Result<T>;

// In avx-http
impl From<HttpError> for avx_error::Error {
    fn from(err: HttpError) -> Self {
        // Convert to avx_error::Error
    }
}

License

Licensed under either of:

at your option.

Commit count: 0

cargo fmt