[CDRIVER-782] Allow more detailed error reporting for failed URI parsing Created: 06/Aug/15 Updated: 02/Nov/17 Resolved: 16/Mar/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.7.0 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Jeremy Mikola | Assignee: | Hannes Magnusson |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Epic Link: | C Driver Connection String Spec | ||||||||||||||||||||||||||||
| Description |
|
It would be helpful for other drivers wrapping libmongoc if URI parsing could return a bson_error_t on error with some details about why parsing failed. Currently, NULL is returned and some messages may have been emitted via MONGOC_WARNING(), which can easily be ignored by the user (especially through another driver atop libmongoc). For example, we might find the following warning messages emitted while parsing read preferences:
These lines even include a comment: "Warn on conflict, since read preference will be validated later"; however, by that point, we've missed the chance to provide a meaningful error (for an exception in PHP's case) to the user. In the case of read preferences and write concerns, validation is deferred until the end of mongoc_uri_new():
The mongoc_read_prefs_is_valid() function (and its WC equivalent) aren't in the business of providing detailed error messages (nor should they be, IMO), but we do have an opportunity to point out errors during URI parsing or when the complex structures (i.e. read preference and write concern) are constructed. |
| Comments |
| Comment by Githook User [ 21/Mar/17 ] |
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: |
| Comment by Githook User [ 16/Mar/17 ] |
|
Author: {u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}Message: |
| Comment by Githook User [ 13/Aug/15 ] |
|
Author: {u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}Message: Split out Manager constructor error tests The extra arguments test can be skipped for HHVM (as was done in #74). The read preference and write concern tests attempt to cover all permutations of invalid arguments. Detailed exceptions are only possible where we apply array options to the structures, since libmongoc currently provides no detailed errors when URI parsing fails (see: |