redjack/libcork — pull request #75 by dcreager (2013-12-06 20:21:47+00:00)
Title: Simpler error API

This patch simplifies the libcork error API. Before, we followed glib's [GError](https://developer.gnome.org/glib/2.37/glib-Error-Reporting.html) API, where there were separate “classes” and “codes” for each custom error condition. The class was meant to identify the library that the custom error belongs to, and the code only had to be unique within each class. GError creates error class values at runtime, using its GQuark mechanism. We used hashes of unique strings as error classes. Error codes were then defined using a simple enum.

This is more cumbersome than it needs to be. With this new patch, we no longer have error classes at all. Individual error codes are now hash values, usually of the name of the error code's macro. (I.e., the value of the `CORK_PARSE_ERROR` error code is the hash of the string `"CORK_PARSE_ERROR"`.) This new design also lets us use the existing, predefined, well-known POSIX `errno` values as error codes directly, which makes it easier to integrate code that uses the POSIX error reporting facilities and libcork's error API.