| Crates.io | nydus-error |
| lib.rs | nydus-error |
| version | 0.2.3 |
| created_at | 2021-08-15 08:10:59.421542+00 |
| updated_at | 2023-01-30 08:18:06.913329+00 |
| description | Error handling utilities for Nydus Image Service |
| homepage | https://nydus.dev/ |
| repository | https://github.com/dragonflyoss/image-service |
| max_upload_size | |
| id | 437171 |
| size | 23,189 |
The nydus-error crate is a collection of helper utilities to handle error codes for Nydus Image Service project, which provides:
macro define_error_macro!() to optionally augment Posix errno with backtrace information.macro einval!(), enoent!() etc for commonly used error codes.struct ErrorHolder to provide a circular buffer to hold the latest error messages.Platforms:
Operating Systems:
Add nydus-error as a dependency in Cargo.toml
[dependencies]
nydus-error = "*"
Then add extern crate nydus-error; to your crate root if needed.
fn check_size(size: usize) -> std::io::Result<()> {
if size > 0x1000 {
return Err(einval!());
}
Ok(())
}
ErrorHolder object.fn record_error(size: usize) {
let mut holder = ErrorHolder::new(10, 80);
let error_msg = "123456789";
let r = holder.push(error_msg);
assert_eq!(r.is_ok(), true);
let _msg = holder.export().unwrap();
}
This code is licensed under Apache-2.0 or BSD-3-Clause.