File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -308,7 +308,7 @@ MONGOCXX_LIBMONGOC_SYMBOL(uri_get_tls)
308
308
MONGOCXX_LIBMONGOC_SYMBOL(uri_get_string)
309
309
MONGOCXX_LIBMONGOC_SYMBOL(uri_get_username)
310
310
MONGOCXX_LIBMONGOC_SYMBOL(uri_get_write_concern)
311
- MONGOCXX_LIBMONGOC_SYMBOL(uri_new )
311
+ MONGOCXX_LIBMONGOC_SYMBOL(uri_new_with_error )
312
312
MONGOCXX_LIBMONGOC_SYMBOL(write_concern_copy)
313
313
MONGOCXX_LIBMONGOC_SYMBOL(write_concern_destroy)
314
314
MONGOCXX_LIBMONGOC_SYMBOL(write_concern_get_journal)
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ TEST_CASE("URI", "[uri]") {
71
71
mongocxx::uri{invalid};
72
72
} catch (const mongocxx::logic_error& e) {
73
73
REQUIRE (e.code () == mongocxx::error_code::k_invalid_uri);
74
+
75
+ std::string invalid_schema =
76
+ " Invalid URI Schema, expecting 'mongodb://' or 'mongodb+srv://': " ;
77
+
78
+ REQUIRE (e.what () == invalid_schema + e.code ().message ());
74
79
}
75
80
}
76
81
Original file line number Diff line number Diff line change @@ -48,10 +48,14 @@ uri::uri(std::unique_ptr<impl>&& implementation) {
48
48
_impl.reset (implementation.release ());
49
49
}
50
50
51
- uri::uri (bsoncxx::string::view_or_value uri_string)
52
- : _impl(stdx::make_unique<impl>(libmongoc::uri_new(uri_string.terminated().data()))) {
51
+ uri::uri (bsoncxx::string::view_or_value uri_string) {
52
+ bson_error_t error;
53
+
54
+ _impl = stdx::make_unique<impl>(
55
+ libmongoc::uri_new_with_error (uri_string.terminated ().data (), &error));
56
+
53
57
if (_impl->uri_t == nullptr ) {
54
- throw logic_error{error_code::k_invalid_uri};
58
+ throw logic_error{error_code::k_invalid_uri, error. message };
55
59
}
56
60
}
57
61
You can’t perform that action at this time.
0 commit comments