Module aerospike::errors
[−]
[src]
Error and Result types for the Aerospike client.
Examples
Handling an error returned by the client.
#[macro_use] extern crate aerospike; use aerospike::*; fn main() { let hosts = std::env::var("AEROSPIKE_HOSTS").unwrap(); let policy = ClientPolicy::default(); let client = Client::new(&policy, &hosts).expect("Failed to connect to cluster"); let key = as_key!("test", "test", "someKey"); match client.get_header(&ReadPolicy::default(), &key) { Ok(record) => { match record.time_to_live() { None => println!("record never expires"), Some(duration) => println!("ttl: {} secs", duration.as_secs()), } }, Err(Error(ErrorKind::ServerError(ResultCode::KeyNotFoundError), _)) => { println!("No such record: {}", key); }, Err(err) => { println!("Error fetching record: {}", err); for err in err.iter().skip(1) { println!("Caused by: {}", err); } // The backtrace is not always generated. Try to run this example // with `RUST_BACKTRACE=1`. if let Some(backtrace) = err.backtrace() { println!("Backtrace: {:?}", backtrace); } } } }
Structs
Error |
The Error type. |
Enums
ErrorKind |
The kind of an error. |
Traits
ResultExt |
Additional methods for |
Type Definitions
Result |
Convenient wrapper around |