1BSON_ERRORS(3) libbson BSON_ERRORS(3)
2
3
4
6 bson_errors - Handling Errors
7
9 Many libbson functions report errors by returning NULL or -1 and fill‐
10 ing out a bson_error_t structure with an error domain, error code, and
11 message.
12
13 · error.domain names the subsystem that generated the error.
14
15 · error.code is a domain-specific error type.
16
17 · error.message describes the error.
18
19 Some error codes overlap with others; always check both the domain and
20 code to determine the type of error.
21
22┌──────────────────┬────────────────────────────────────┬────────────────────────────────┐
23│BSON_ERROR_JSON │ BSON_JSON_ERROR_READ_COR‐ │ bson_json_reader_t │
24│ │ RUPT_JS │ tried to parse │
25│ │ BSON_JSON_ERROR_READ_INVALID_PARAM │ invalid MongoDB │
26│ │ BSON_JSON_ERROR_READ_CB_FAIL‐ │ Extended JSON. │
27│ │ URE │ Tried to parse a │
28│ │ │ valid JSON document │
29│ │ │ that is invalid as │
30│ │ │ MongoDBExtended │
31│ │ │ JSON. An internal │
32│ │ │ callback failure │
33│ │ │ during JSON pars‐ │
34│ │ │ ing. │
35├──────────────────┼────────────────────────────────────┼────────────────────────────────┤
36│BSON_ERROR_READER │ BSON_ERROR_READER_BADFD │ bson_json_reader_new_from_file │
37│ │ │ could not open the │
38│ │ │ file. │
39└──────────────────┴────────────────────────────────────┴────────────────────────────────┘
40
42 MongoDB, Inc
43
45 2017-present, MongoDB, Inc
46
47
48
49
501.16.2 Feb 25, 2020 BSON_ERRORS(3)