Merge pull request #29 from thijsc/error_code_update

Error code update
pull/30/head
Thijs Cadier 7 years ago committed by GitHub
commit 09de0848eb

@ -14,14 +14,26 @@ The API should still be considered experimental, but I'm not expecting changes a
## Compatibility ## Compatibility
The driver currently only builds on Unix, tested on Mac Os X and Linux so far. It's compatible with MongoDB 2.4 up to 3.4 and The driver currently only builds on Unix, tested on Mac Os X and Linux so far. It's compatible with MongoDB 2.6 up to 3.4 and has full replica set and SSL support.
has full replica set and SSL support.
## Installation ## Installation
If you have any trouble installing the crate (linking openssl can be If you have any trouble installing the crate (linking openssl can be
tricky) please check out the [installation instructions for the C driver](http://mongoc.org/libmongoc/current/installing.html). tricky) please check out the [installation instructions for the C driver](http://mongoc.org/libmongoc/current/installing.html).
To build on Mac install OpenSSL 1.1:
```
brew install openssl@1.1
```
Export these env vars the before you make a clean build:
```
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
``
## Logging ## Logging
All internal logging by mongoc is redirected to the macros in the [log All internal logging by mongoc is redirected to the macros in the [log

@ -249,4 +249,6 @@ pub mod bindings {
pub const MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND: ::libc::c_uint = 59; pub const MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND: ::libc::c_uint = 59;
pub const MONGOC_ERROR_QUERY_NOT_TAILABLE: ::libc::c_uint = 13051; pub const MONGOC_ERROR_QUERY_NOT_TAILABLE: ::libc::c_uint = 13051;
pub const MONGOC_ERROR_PROTOCOL_ERROR: ::libc::c_uint = 17; pub const MONGOC_ERROR_PROTOCOL_ERROR: ::libc::c_uint = 17;
pub const MONGOC_ERROR_WRITE_CONCERN_ERROR: ::libc::c_uint = 64;
pub const MONGOC_ERROR_DUPLICATE_KEY: ::libc::c_uint = 11000;
} }

@ -146,7 +146,9 @@ pub enum MongoErrorCode {
ScramProtocolError, ScramProtocolError,
QueryCommandNotFound, QueryCommandNotFound,
QueryNotTailable, QueryNotTailable,
Unknown WriteConcernError,
DuplicateKey,
Unknown(u32)
} }
impl BsoncError { impl BsoncError {
@ -222,7 +224,9 @@ impl BsoncError {
bindings::MONGOC_ERROR_SCRAM_PROTOCOL_ERROR => MongoErrorCode::ScramProtocolError, bindings::MONGOC_ERROR_SCRAM_PROTOCOL_ERROR => MongoErrorCode::ScramProtocolError,
bindings::MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND => MongoErrorCode::QueryCommandNotFound, bindings::MONGOC_ERROR_QUERY_COMMAND_NOT_FOUND => MongoErrorCode::QueryCommandNotFound,
bindings::MONGOC_ERROR_QUERY_NOT_TAILABLE => MongoErrorCode::QueryNotTailable, bindings::MONGOC_ERROR_QUERY_NOT_TAILABLE => MongoErrorCode::QueryNotTailable,
_ => MongoErrorCode::Unknown bindings::MONGOC_ERROR_WRITE_CONCERN_ERROR => MongoErrorCode::WriteConcernError,
bindings::MONGOC_ERROR_DUPLICATE_KEY => MongoErrorCode::DuplicateKey,
code => MongoErrorCode::Unknown(code)
} }
} }

Loading…
Cancel
Save