Many functions in Libbson can result in errors. To simplify this, Libbson contains a structure called out parameter.. This structure enapsulates an error from the underlying system and can be passed back up the stack. Think of it as an exception as an
The structure contains domain and code fields that can be used to check for specific error conditions. The value of these fields is API specific. If you simply want to print an error message, use the message field of .
Functions that can result in error specify the return value that indicates the error out parameter was initialized. Typically this is 0 or NULL, but may sometimes be -1 depending on the API.
This structure should be stack-allocated and requires no explicit freeing.