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_ER‐ │ bson_json_reader_t │
24 │ │ ROR_READ_CORRUPT_JS │ tried to parse in‐ │
25 │ │ BSON_JSON_ER‐ │ valid MongoDB Ex‐ │
26 │ │ ROR_READ_IN‐ │ tended JSON. Tried │
27 │ │ VALID_PARAM │ to parse a valid │
28 │ │ BSON_JSON_ER‐ │ JSON document that │
29 │ │ ROR_READ_CB_FAILURE │ is invalid as Mon‐ │
30 │ │ │ goDBExtended JSON. │
31 │ │ │ An internal call‐ │
32 │ │ │ back failure during │
33 │ │ │ JSON parsing. │
34 ├──────────────────┼─────────────────────┼──────────────────────────────────┤
35 │BSON_ERROR_READER │ BSON_ER‐ │ bson_json_reader_new_from_file() │
36 │ │ ROR_READER_BADFD │ could not open the │
37 │ │ │ file. │
38 └──────────────────┴─────────────────────┴──────────────────────────────────┘
39
41 MongoDB, Inc
42
44 2017-present, MongoDB, Inc
45
46
47
48
491.23.1 Oct 20, 2022 BSON_ERRORS(3)