|
|
@ -4,6 +4,7 @@ use std::borrow::Cow;
|
|
|
|
use std::ffi::CStr;
|
|
|
|
use std::ffi::CStr;
|
|
|
|
|
|
|
|
|
|
|
|
use bson::{DecoderError,EncoderError,ValueAccessError,Document};
|
|
|
|
use bson::{DecoderError,EncoderError,ValueAccessError,Document};
|
|
|
|
|
|
|
|
use std::ffi::NulError;
|
|
|
|
|
|
|
|
|
|
|
|
use mongoc::bindings;
|
|
|
|
use mongoc::bindings;
|
|
|
|
|
|
|
|
|
|
|
@ -18,7 +19,9 @@ pub enum MongoError {
|
|
|
|
/// Error accessing a value on a Bson document.
|
|
|
|
/// Error accessing a value on a Bson document.
|
|
|
|
ValueAccessError(ValueAccessError),
|
|
|
|
ValueAccessError(ValueAccessError),
|
|
|
|
/// Invalid params error that can be reported by the underlying C driver.
|
|
|
|
/// Invalid params error that can be reported by the underlying C driver.
|
|
|
|
InvalidParams(InvalidParamsError)
|
|
|
|
InvalidParams(InvalidParamsError),
|
|
|
|
|
|
|
|
// from CString::new(db)
|
|
|
|
|
|
|
|
Nul(NulError)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for MongoError {
|
|
|
|
impl fmt::Display for MongoError {
|
|
|
@ -28,7 +31,8 @@ impl fmt::Display for MongoError {
|
|
|
|
MongoError::Encoder(ref err) => write!(f, "{}", err),
|
|
|
|
MongoError::Encoder(ref err) => write!(f, "{}", err),
|
|
|
|
MongoError::Decoder(ref err) => write!(f, "{}", err),
|
|
|
|
MongoError::Decoder(ref err) => write!(f, "{}", err),
|
|
|
|
MongoError::ValueAccessError(ref err) => write!(f, "{}", err),
|
|
|
|
MongoError::ValueAccessError(ref err) => write!(f, "{}", err),
|
|
|
|
MongoError::InvalidParams(ref err) => write!(f, "{}", err)
|
|
|
|
MongoError::InvalidParams(ref err) => write!(f, "{}", err),
|
|
|
|
|
|
|
|
MongoError::Nul(ref err) => write!(f, "{}", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -40,7 +44,8 @@ impl fmt::Debug for MongoError {
|
|
|
|
MongoError::Decoder(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
MongoError::Decoder(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
MongoError::Encoder(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
MongoError::Encoder(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
MongoError::ValueAccessError(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
MongoError::ValueAccessError(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
MongoError::InvalidParams(ref err) => write!(f, "MongoError ({:?})", err)
|
|
|
|
MongoError::InvalidParams(ref err) => write!(f, "MongoError ({:?})", err),
|
|
|
|
|
|
|
|
MongoError::Nul(ref err) => write!(f, "MongoError ({:?})", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -52,7 +57,8 @@ impl error::Error for MongoError {
|
|
|
|
MongoError::Decoder(ref err) => err.description(),
|
|
|
|
MongoError::Decoder(ref err) => err.description(),
|
|
|
|
MongoError::Encoder(ref err) => err.description(),
|
|
|
|
MongoError::Encoder(ref err) => err.description(),
|
|
|
|
MongoError::ValueAccessError(ref err) => err.description(),
|
|
|
|
MongoError::ValueAccessError(ref err) => err.description(),
|
|
|
|
MongoError::InvalidParams(ref err) => err.description()
|
|
|
|
MongoError::InvalidParams(ref err) => err.description(),
|
|
|
|
|
|
|
|
MongoError::Nul(ref err) => err.description()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -62,7 +68,8 @@ impl error::Error for MongoError {
|
|
|
|
MongoError::Decoder(ref err) => Some(err),
|
|
|
|
MongoError::Decoder(ref err) => Some(err),
|
|
|
|
MongoError::Encoder(ref err) => Some(err),
|
|
|
|
MongoError::Encoder(ref err) => Some(err),
|
|
|
|
MongoError::ValueAccessError(ref err) => Some(err),
|
|
|
|
MongoError::ValueAccessError(ref err) => Some(err),
|
|
|
|
MongoError::InvalidParams(ref err) => Some(err)
|
|
|
|
MongoError::InvalidParams(ref err) => Some(err),
|
|
|
|
|
|
|
|
MongoError::Nul(ref err) => Some(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -85,6 +92,12 @@ impl From<ValueAccessError> for MongoError {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl From<NulError> for MongoError {
|
|
|
|
|
|
|
|
fn from(error: NulError) -> MongoError {
|
|
|
|
|
|
|
|
MongoError::Nul(error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Error in the underlying C driver.
|
|
|
|
/// Error in the underlying C driver.
|
|
|
|
pub struct BsoncError {
|
|
|
|
pub struct BsoncError {
|
|
|
|
inner: bindings::bson_error_t,
|
|
|
|
inner: bindings::bson_error_t,
|
|
|
|