aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2017-10-03 11:42:07 +0200
committerPhilipp Stephani <phst@google.com>2017-10-03 11:42:07 +0200
commit112ccbd820449b85d7a7541d6b39cb31bdbb1bbb (patch)
tree5a2baa21a46d6d8ff2ae297cb7c3c60ba7327836 /doc
parent271ffda903d2b64e3971f41a3e03af1ad0ddc217 (diff)
downloadjansson-112ccbd820449b85d7a7541d6b39cb31bdbb1bbb.zip
jansson-112ccbd820449b85d7a7541d6b39cb31bdbb1bbb.tar.gz
jansson-112ccbd820449b85d7a7541d6b39cb31bdbb1bbb.tar.bz2
Use last byte of error text as numeric error code
Fixes #352
Diffstat (limited to 'doc')
-rw-r--r--doc/apiref.rst90
1 files changed, 90 insertions, 0 deletions
diff --git a/doc/apiref.rst b/doc/apiref.rst
index 703261e..54d5c7e 100644
--- a/doc/apiref.rst
+++ b/doc/apiref.rst
@@ -813,6 +813,9 @@ this struct.
The error message (in UTF-8), or an empty string if a message is
not available.
+ The last byte of this array contains a numeric error code. Use
+ :func:`json_error_code()` to extract this code.
+
.. member:: char source[]
Source of the error. This can be (a part of) the file name or a
@@ -855,6 +858,93 @@ success. See :ref:`apiref-decoding` for more info.
All functions also accept *NULL* as the :type:`json_error_t` pointer,
in which case no error information is returned to the caller.
+.. type:: enum json_error_code
+
+ An enumeration containing numeric error codes. The following errors are
+ currently defined:
+
+ ``json_error_unknown``
+
+ Unknown error. This should only be returned for non-errorneous
+ :type:`json_error_t` structures.
+
+ ``json_error_out_of_memory``
+
+ The library couldn’t allocate any heap memory.
+
+ ``json_error_stack_overflow``
+
+ Nesting too deep.
+
+ ``json_error_cannot_open_file``
+
+ Couldn’t open input file.
+
+ ``json_error_invalid_argument``
+
+ A function argument was invalid.
+
+ ``json_error_invalid_utf8``
+
+ The input string isn’t valid UTF-8.
+
+ ``json_error_premature_end_of_input``
+
+ The input ended in the middle of a JSON value.
+
+ ``json_error_end_of_input_expected``
+
+ There was some text after the end of a JSON value. See the
+ ``JSON_DISABLE_EOF_CHECK`` flag.
+
+ ``json_error_invalid_syntax``
+
+ JSON syntax error.
+
+ ``json_error_invalid_format``
+
+ Invalid format string for packing or unpacking.
+
+ ``json_error_wrong_type``
+
+ When packing or unpacking, the actual type of a value differed from the
+ one specified in the format string.
+
+ ``json_error_null_character``
+
+ A null character was detected in a JSON string. See the
+ ``JSON_ALLOW_NUL`` flag.
+
+ ``json_error_null_value``
+
+ When packing or unpacking, some key or value was ``NULL``.
+
+ ``json_error_null_byte_in_key``
+
+ An object key would contain a null byte. Jansson can’t represent such
+ keys; see :ref:`rfc-conformance`.
+
+ ``json_error_duplicate_key``
+
+ Duplicate key in object. See the ``JSON_REJECT_DUPLICATES`` flag.
+
+ ``json_error_numeric_overflow``
+
+ When converting a JSON number to a C numeric type, a numeric overflow
+ was detected.
+
+ ``json_error_item_not_found``
+
+ Key in object not found.
+
+ ``json_error_index_out_of_range``
+
+ Array index is out of range.
+
+.. function:: enum json_error_code json_error_code(const json_error_t *error)
+
+ Returns the error code embedded in ``error->text``.
+
Encoding
========