summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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