<?xml version="1.0"?>
<page id="bson_error_t"
      type="guide"
      style="class"
      xmlns="http://projectmallard.org/1.0/"
      xmlns:api="http://projectmallard.org/experimental/api/"
      xmlns:ui="http://projectmallard.org/experimental/ui/">

  <info>
    <link type="guide" xref="index#api-reference" />
  </info>

  <title>bson_error_t</title>
  <subtitle>BSON Error Encapsulation</subtitle>

  <section id="description">
    <title>Synopsis</title>
    <synopsis><code mime="text/x-csrc"><![CDATA[#include <bson.h>

typedef struct
{
   uint32_t domain;
   uint32_t code;
   char     message[504];
} bson_error_t;]]></code></synopsis>
  </section>

  <section id="description">
    <title>Description</title>
    <p>The <link xref="bson_error_t">bson_error_t</link> structure is used to encapsulate information about an error. Think of it as the information stored in an exception without stack trace information. It includes information about the module and error code of the error along with a human printable message.</p>
    <p>The <code>error.domain</code> field contains the logical domain within a library that created the error. This might be the JSON subsystem or <link xref="bson_reader_t">bson_reader_t</link> for example.</p>
    <p>The <code>error.code</code> field contains the domain specific error code.</p>
    <p>The <code>error.message</code> field contains a human printable error message.</p>
  </section>

  <links type="topic" groups="function" style="2column">
    <title>Functions</title>
  </links>

  <section id="examples">
    <title>Example</title>
    <listing>
      <title>Print Error Information</title>
      <synopsis><code mime="text/x-csrc"><![CDATA[bson_reader_t *reader;
bson_error_t error;

reader = bson_reader_new_from_file ("dump.bson", &error);
if (!reader) {
   fprintf (stderr, "ERROR: %d.%d: %s\n",
            error.domain, error.code, error.message);
}]]></code></synopsis>
    </listing>
  </section>
</page>
