summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2017-02-04 16:12:32 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2017-02-04 16:21:44 (GMT)
commit46305b75b9a4ec8f0e4a93e3efb1b8e12ff2f390 (patch)
treedc3b492f2b8e3ed7f73f59fd1efbf44b1c29c529
parent68684b13e888b1be4aa9c2c5d47da85ac5351223 (diff)
downloadlibnslayout-46305b75b9a4ec8f0e4a93e3efb1b8e12ff2f390.tar.gz
libnslayout-46305b75b9a4ec8f0e4a93e3efb1b8e12ff2f390.tar.bz2
error: Improve error header.
-rw-r--r--include/libnslayout/error.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/include/libnslayout/error.h b/include/libnslayout/error.h
index 0e2321f..5e7b87a 100644
--- a/include/libnslayout/error.h
+++ b/include/libnslayout/error.h
@@ -17,25 +17,42 @@ extern "C"
#endif
/**
+ * Number of bits in an `nslayout_error` that indicate the source of the error.
+ */
+#define NSLAYOUT_ERROR_PROV 8
+
+/**
* Libnslayout return codes
*
* NSLAYOUT_OK indicates no error.
*/
typedef enum nslayout_error {
/** No error code */
- NSLAYOUT_OK = 0,
+ NSLAYOUT_OK = 0,
- /** Error provenance */
- NSLAYOUT_NSLAYOUT = (1 << 0),
- NSLAYOUT_LIBDOM = (1 << 1),
- NSLAYOUT_LIBCSS = (1 << 2),
+ /** Error provenance (bits 0..7) */
+ NSLAYOUT_NSLAYOUT = (1 << 0),
+ NSLAYOUT_LIBDOM = (1 << 1),
+ NSLAYOUT_LIBCSS = (1 << 2),
- /** LibNSLayout errors */
- NSLAYOUT_NO_MEM = (1 << 8) + NSLAYOUT_NSLAYOUT,
+ /** LibNSLayout errors (bits 8..31) */
+ NSLAYOUT_NO_MEM = (1 << NSLAYOUT_ERROR_PROV) | NSLAYOUT_NSLAYOUT,
} nslayout_error;
/**
+ * Get error provenance.
+ *
+ * \param[in] err Error code to test
+ * \return error provenance
+ */
+static inline nslayout_error nslayout_error_provenance(nslayout_error err)
+{
+ return err & ((1 << NSLAYOUT_ERROR_PROV) - 1);
+}
+
+
+/**
* Check if error is from libnslayout
*
* \param[in] err Error code to test