[cogl] Adds CoglError api



commit b068d5ea09ab32c37e8c965fc8582c85d1b2db46
Author: Robert Bragg <robert linux intel com>
Date:   Fri Aug 31 19:28:27 2012 +0100

    Adds CoglError api
    
    Although we use GLib internally in Cogl we would rather not leak GLib
    api through Cogl's own api, except through explicitly namespaced
    cogl_glib_ / cogl_gtype_ feature apis.
    
    One of the benefits we see to not leaking GLib through Cogl's public API
    is that documentation for Cogl won't need to first introduce the Glib
    API to newcomers, thus hopefully lowering the barrier to learning Cogl.
    
    This patch provides a Cogl specific typedef for reporting runtime errors
    which by no coincidence matches the typedef for GError exactly.  If Cogl
    is built with --enable-glib (default) then developers can even safely
    assume that a CoglError is a GError under the hood.
    
    This patch also enforces a consistent policy for when NULL is passed as
    an error argument and an error is thrown. In this case we log the error
    and abort the application, instead of silently ignoring it. In common
    cases where nothing has been implemented to handle a particular error
    and/or where applications are just printing the error and aborting
    themselves then this saves some typing. This also seems more consistent
    with language based exceptions which usually cause a program to abort if
    they are not explicitly caught (which passing a non-NULL error signifies
    in this case)
    
    Since this policy for NULL error pointers is stricter than the standard
    GError convention, there is a clear note in the documentation to warn
    developers that are used to using the GError api.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 cogl/Makefile.am                          |    3 +
 cogl/cogl-bitmap-pixbuf.c                 |   97 +++++++++--------
 cogl/cogl-bitmap-private.h                |    4 +-
 cogl/cogl-bitmap.c                        |    8 +-
 cogl/cogl-bitmap.h                        |   14 +-
 cogl/cogl-blend-string.c                  |   79 +++++++-------
 cogl/cogl-blend-string.h                  |    2 +-
 cogl/cogl-context-private.h               |    2 +-
 cogl/cogl-context.c                       |   26 +++--
 cogl/cogl-context.h                       |    4 +-
 cogl/cogl-display.c                       |    4 +-
 cogl/cogl-display.h                       |    4 +-
 cogl/cogl-driver.h                        |    2 +-
 cogl/cogl-error-private.h                 |   48 ++++++++
 cogl/cogl-error.c                         |  109 ++++++++++++++++++
 cogl/cogl-error.h                         |  171 +++++++++++++++++++++++++++++
 cogl/cogl-framebuffer.c                   |   15 ++-
 cogl/cogl-framebuffer.h                   |   10 +-
 cogl/cogl-gles2-context.c                 |   29 +++---
 cogl/cogl-gles2.h                         |   16 ++--
 cogl/cogl-internal.h                      |    6 +-
 cogl/cogl-pipeline-layer-state.c          |   28 ++---
 cogl/cogl-pipeline-layer-state.h          |    8 +-
 cogl/cogl-pipeline-state.c                |   28 ++---
 cogl/cogl-pipeline-state.h                |    8 +-
 cogl/cogl-renderer.c                      |   25 ++--
 cogl/cogl-renderer.h                      |   15 ++-
 cogl/cogl-sdl.c                           |    2 +-
 cogl/cogl-sdl.h                           |    6 +-
 cogl/cogl-texture-2d-private.h            |    2 +-
 cogl/cogl-texture-2d-sliced.c             |   15 ++-
 cogl/cogl-texture-2d-sliced.h             |    4 +-
 cogl/cogl-texture-2d.c                    |   44 ++++----
 cogl/cogl-texture-2d.h                    |   16 ++--
 cogl/cogl-texture-3d.c                    |   41 ++++----
 cogl/cogl-texture-3d.h                    |   16 ++--
 cogl/cogl-texture-rectangle.c             |   23 ++--
 cogl/cogl-texture-rectangle.h             |    8 +-
 cogl/cogl-texture.c                       |    6 +-
 cogl/cogl-texture.h                       |   10 +-
 cogl/cogl-types.h                         |   34 +++---
 cogl/cogl-wayland-server.h                |    4 +-
 cogl/cogl-xlib-renderer-private.h         |    2 +-
 cogl/cogl-xlib-renderer.c                 |    7 +-
 cogl/cogl.c                               |   10 +-
 cogl/cogl.h                               |    1 +
 cogl/cogl.symbols                         |   14 +-
 cogl/driver/gl/cogl-gl.c                  |   11 +-
 cogl/driver/gles/cogl-gles.c              |    2 +-
 cogl/winsys/cogl-texture-pixmap-x11.c     |   11 +-
 cogl/winsys/cogl-texture-pixmap-x11.h     |   10 +-
 cogl/winsys/cogl-winsys-egl-android.c     |   12 +-
 cogl/winsys/cogl-winsys-egl-gdl.c         |   26 ++--
 cogl/winsys/cogl-winsys-egl-kms.c         |   37 +++---
 cogl/winsys/cogl-winsys-egl-null.c        |   12 +-
 cogl/winsys/cogl-winsys-egl-private.h     |   10 +-
 cogl/winsys/cogl-winsys-egl-wayland.c     |   19 ++--
 cogl/winsys/cogl-winsys-egl-x11.c         |   19 ++--
 cogl/winsys/cogl-winsys-egl.c             |   31 +++---
 cogl/winsys/cogl-winsys-glx.c             |   61 +++++-----
 cogl/winsys/cogl-winsys-private.h         |   18 ++--
 cogl/winsys/cogl-winsys-sdl.c             |   19 ++--
 cogl/winsys/cogl-winsys-sdl2.c            |   22 ++--
 cogl/winsys/cogl-winsys-stub.c            |    8 +-
 cogl/winsys/cogl-winsys-wgl.c             |   26 ++--
 cogl/winsys/cogl-winsys.c                 |    4 +-
 doc/reference/cogl2/cogl2-docs.xml.in     |    1 +
 doc/reference/cogl2/cogl2-sections.txt    |   12 ++-
 examples/android/hello/jni/main.c         |    2 +-
 examples/cogl-crate.c                     |    2 +-
 examples/cogl-gles2-context.c             |    4 +-
 examples/cogl-gles2-gears.c               |    4 +-
 examples/cogl-hello.c                     |    2 +-
 examples/cogl-info.c                      |    2 +-
 examples/cogl-msaa.c                      |    6 +-
 examples/cogl-sdl-hello.c                 |    2 +-
 examples/cogl-sdl2-hello.c                |    2 +-
 examples/cogl-x11-foreign.c               |    2 +-
 examples/cogl-x11-tfp.c                   |    2 +-
 examples/cogland.c                        |    6 +-
 tests/conform/test-blend-strings.c        |    4 +-
 tests/conform/test-gles2-context.c        |   12 +-
 tests/conform/test-just-vertex-shader.c   |    2 +-
 tests/conform/test-multitexture.c         |    2 +-
 tests/conform/test-pipeline-user-matrix.c |    2 +-
 tests/conform/test-point-sprite.c         |    2 +-
 tests/conform/test-sub-texture.c          |    9 +-
 tests/conform/test-texture-3d.c           |    2 +-
 tests/conform/test-utils.c                |    2 +-
 89 files changed, 914 insertions(+), 560 deletions(-)
---
diff --git a/cogl/Makefile.am b/cogl/Makefile.am
index f8e6e18..c9c02d4 100644
--- a/cogl/Makefile.am
+++ b/cogl/Makefile.am
@@ -105,6 +105,7 @@ cogl_experimental_h = \
 	$(srcdir)/cogl-buffer.h 		\
 	$(srcdir)/cogl-pixel-buffer.h		\
 	$(srcdir)/cogl-version.h		\
+	$(srcdir)/cogl-error.h			\
 	$(NULL)
 
 cogl_nodist_experimental_h = \
@@ -354,6 +355,8 @@ cogl_sources_c = \
 	$(srcdir)/cogl-magazine.c			\
 	$(srcdir)/cogl-gles2-context-private.h		\
 	$(srcdir)/cogl-gles2-context.c			\
+	$(srcdir)/cogl-error-private.h			\
+	$(srcdir)/cogl-error.c				\
 	$(NULL)
 
 if USE_GLIB
diff --git a/cogl/cogl-bitmap-pixbuf.c b/cogl/cogl-bitmap-pixbuf.c
index ba31c56..0af32b1 100644
--- a/cogl/cogl-bitmap-pixbuf.c
+++ b/cogl/cogl-bitmap-pixbuf.c
@@ -30,6 +30,7 @@
 #include "cogl-bitmap-private.h"
 #include "cogl-context-private.h"
 #include "cogl-private.h"
+#include "cogl-error-private.h"
 
 #include <string.h>
 
@@ -59,7 +60,7 @@ _cogl_bitmap_get_size_from_file (const char *filename,
 CoglBitmap *
 _cogl_bitmap_from_file (CoglContext *ctx,
                         const char *filename,
-			GError **error)
+			CoglError **error)
 {
   CFURLRef url;
   CGImageSourceRef image_source;
@@ -83,10 +84,10 @@ _cogl_bitmap_from_file (CoglContext *ctx,
   if (image_source == NULL)
     {
       /* doesn't exist, not readable, etc. */
-      g_set_error_literal (error,
-                           COGL_BITMAP_ERROR,
-                           COGL_BITMAP_ERROR_FAILED,
-                           g_strerror (save_errno));
+      _cogl_set_error_literal (error,
+                               COGL_BITMAP_ERROR,
+                               COGL_BITMAP_ERROR_FAILED,
+                               g_strerror (save_errno));
       return NULL;
     }
 
@@ -97,10 +98,10 @@ _cogl_bitmap_from_file (CoglContext *ctx,
   if (type == NULL)
     {
       CFRelease (image_source);
-      g_set_error_literal (error,
-                           COGL_BITMAP_ERROR,
-                           COGL_BITMAP_ERROR_UNKNOWN_TYPE,
-                           "Unknown image type");
+      _cogl_set_error_literal (error,
+                               COGL_BITMAP_ERROR,
+                               COGL_BITMAP_ERROR_UNKNOWN_TYPE,
+                               "Unknown image type");
       return NULL;
     }
 
@@ -115,10 +116,10 @@ _cogl_bitmap_from_file (CoglContext *ctx,
     {
       /* incomplete or corrupt */
       CFRelease (image);
-      g_set_error_literal (error,
-                           COGL_BITMAP_ERROR,
-                           COGL_BITMAP_ERROR_CORRUPT_IMAGE,
-                           "Image has zero width or height");
+      _cogl_set_error_literal (error,
+                               COGL_BITMAP_ERROR,
+                               COGL_BITMAP_ERROR_CORRUPT_IMAGE,
+                               "Image has zero width or height");
       return NULL;
     }
 
@@ -174,24 +175,28 @@ _cogl_bitmap_get_size_from_file (const char *filename,
 CoglBitmap *
 _cogl_bitmap_from_file (CoglContext *ctx,
                         const char *filename,
-			GError **error)
+			CoglError **error)
 {
   static CoglUserDataKey pixbuf_key;
-  GdkPixbuf        *pixbuf;
-  CoglBool          has_alpha;
-  GdkColorspace     color_space;
-  CoglPixelFormat   pixel_format;
-  int               width;
-  int               height;
-  int               rowstride;
-  int               bits_per_sample;
-  int               n_channels;
-  CoglBitmap       *bmp;
+  GdkPixbuf *pixbuf;
+  CoglBool has_alpha;
+  GdkColorspace color_space;
+  CoglPixelFormat pixel_format;
+  int width;
+  int height;
+  int rowstride;
+  int bits_per_sample;
+  int n_channels;
+  CoglBitmap *bmp;
+  GError *glib_error = NULL;
 
   /* Load from file using GdkPixbuf */
-  pixbuf = gdk_pixbuf_new_from_file (filename, error);
+  pixbuf = gdk_pixbuf_new_from_file (filename, &glib_error);
   if (pixbuf == NULL)
-    return FALSE;
+    {
+      _cogl_propogate_gerror (error, glib_error);
+      return FALSE;
+    }
 
   /* Get pixbuf properties */
   has_alpha       = gdk_pixbuf_get_has_alpha (pixbuf);
@@ -308,7 +313,7 @@ _cogl_bitmap_new_from_stb_pixels (CoglContext *ctx,
                                   int stb_pixel_format,
                                   int width,
                                   int height,
-                                  GError **error)
+                                  CoglError **error)
 {
   static CoglUserDataKey bitmap_data_key;
   CoglBitmap *bmp;
@@ -317,10 +322,10 @@ _cogl_bitmap_new_from_stb_pixels (CoglContext *ctx,
 
   if (pixels == NULL)
     {
-      g_set_error_literal (error,
-                           COGL_BITMAP_ERROR,
-                           COGL_BITMAP_ERROR_FAILED,
-                           "Failed to load image with stb image library");
+      _cogl_set_error_literal (error,
+                               COGL_BITMAP_ERROR,
+                               COGL_BITMAP_ERROR_FAILED,
+                               "Failed to load image with stb image library");
       return NULL;
     }
 
@@ -338,11 +343,11 @@ _cogl_bitmap_new_from_stb_pixels (CoglContext *ctx,
 
         if (!pixels)
           {
-            g_set_error_literal (error,
-                                 COGL_BITMAP_ERROR,
-                                 COGL_BITMAP_ERROR_FAILED,
-                                 "Failed to alloc memory to convert "
-                                 "gray_alpha to rgba8888");
+            _cogl_set_error_literal (error,
+                                     COGL_BITMAP_ERROR,
+                                     COGL_BITMAP_ERROR_FAILED,
+                                     "Failed to alloc memory to convert "
+                                     "gray_alpha to rgba8888");
             return NULL;
           }
 
@@ -380,7 +385,7 @@ _cogl_bitmap_new_from_stb_pixels (CoglContext *ctx,
 CoglBitmap *
 _cogl_bitmap_from_file (CoglContext *ctx,
                         const char *filename,
-			GError **error)
+			CoglError **error)
 {
   int stb_pixel_format;
   int width;
@@ -401,7 +406,7 @@ CoglBitmap *
 _cogl_android_bitmap_new_from_asset (CoglContext *ctx,
                                      AAssetManager *manager,
                                      const char *filename,
-                                     GError **error)
+                                     CoglError **error)
 {
   AAsset *asset;
   const void *data;
@@ -415,20 +420,20 @@ _cogl_android_bitmap_new_from_asset (CoglContext *ctx,
   asset = AAssetManager_open (manager, filename, AASSET_MODE_BUFFER);
   if (!asset)
     {
-      g_set_error_literal (error,
-                           COGL_BITMAP_ERROR,
-                           COGL_BITMAP_ERROR_FAILED,
-                           "Failed to open asset");
+      _cogl_set_error_literal (error,
+                               COGL_BITMAP_ERROR,
+                               COGL_BITMAP_ERROR_FAILED,
+                               "Failed to open asset");
       return NULL;
     }
 
   data = AAsset_getBuffer (asset);
   if (!data)
     {
-      g_set_error_literal (error,
-                           COGL_BITMAP_ERROR,
-                           COGL_BITMAP_ERROR_FAILED,
-                           "Failed to ::getBuffer from asset");
+      _cogl_set_error_literal (error,
+                               COGL_BITMAP_ERROR,
+                               COGL_BITMAP_ERROR_FAILED,
+                               "Failed to ::getBuffer from asset");
       return NULL;
     }
 
diff --git a/cogl/cogl-bitmap-private.h b/cogl/cogl-bitmap-private.h
index c74c862..e0cf11d 100644
--- a/cogl/cogl-bitmap-private.h
+++ b/cogl/cogl-bitmap-private.h
@@ -109,14 +109,14 @@ _cogl_bitmap_convert_into_bitmap (CoglBitmap *src_bmp,
 CoglBitmap *
 _cogl_bitmap_from_file (CoglContext *ctx,
                         const char *filename,
-			GError **error);
+			CoglError **error);
 
 #ifdef COGL_HAS_ANDROID_SUPPORT
 CoglBitmap *
 _cogl_android_bitmap_new_from_asset (CoglContext *ctx,
                                      AAssetManager *manager,
                                      const char *filename,
-                                     GError **error);
+                                     CoglError **error);
 #endif
 
 CoglBool
diff --git a/cogl/cogl-bitmap.c b/cogl/cogl-bitmap.c
index af52de8..c6025fd 100644
--- a/cogl/cogl-bitmap.c
+++ b/cogl/cogl-bitmap.c
@@ -229,7 +229,7 @@ _cogl_bitmap_new_shared (CoglBitmap              *shared_bmp,
 CoglBitmap *
 cogl_bitmap_new_from_file (CoglContext *ctx,
                            const char *filename,
-                           GError **error)
+                           CoglError **error)
 {
   _COGL_RETURN_VAL_IF_FAIL (filename != NULL, NULL);
   _COGL_RETURN_VAL_IF_FAIL (error == NULL || *error == NULL, NULL);
@@ -300,7 +300,7 @@ CoglBitmap *
 cogl_android_bitmap_new_from_asset (CoglContext *ctx,
                                     AAssetManager *manager,
                                     const char *filename,
-                                    GError **error)
+                                    CoglError **error)
 {
   _COGL_RETURN_VAL_IF_FAIL (ctx != NULL, NULL);
   _COGL_RETURN_VAL_IF_FAIL (manager != NULL, NULL);
@@ -351,8 +351,8 @@ cogl_bitmap_get_buffer (CoglBitmap *bitmap)
   return COGL_PIXEL_BUFFER (bitmap->buffer);
 }
 
-GQuark
-cogl_bitmap_error_quark (void)
+uint32_t
+cogl_bitmap_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-bitmap-error-quark");
 }
diff --git a/cogl/cogl-bitmap.h b/cogl/cogl-bitmap.h
index e54ac31..9aeaeb4 100644
--- a/cogl/cogl-bitmap.h
+++ b/cogl/cogl-bitmap.h
@@ -56,7 +56,7 @@ typedef struct _CoglBitmap CoglBitmap;
  * cogl_bitmap_new_from_file:
  * @context: A #CoglContext
  * @filename: the file to load.
- * @error: a #GError or %NULL.
+ * @error: a #CoglError or %NULL.
  *
  * Loads an image file from disk. This function can be safely called from
  * within a thread.
@@ -69,7 +69,7 @@ typedef struct _CoglBitmap CoglBitmap;
 CoglBitmap *
 cogl_bitmap_new_from_file (CoglContext *context,
                            const char *filename,
-                           GError **error);
+                           CoglError **error);
 
 #ifdef COGL_HAS_ANDROID_SUPPORT
 /**
@@ -77,7 +77,7 @@ cogl_bitmap_new_from_file (CoglContext *context,
  * @context: A #CoglContext
  * @manager: An Android Asset Manager.
  * @filename: The file name for the asset
- * @error: A return location for a GError exception.
+ * @error: A return location for a CoglError exception.
  *
  * Loads an Android asset into a newly allocated #CoglBitmap.
  *
@@ -90,7 +90,7 @@ CoglBitmap *
 cogl_android_bitmap_new_from_asset (CoglContext *context,
                                     AAssetManager *manager,
                                     const char *filename,
-                                    GError **error);
+                                    CoglError **error);
 #endif
 
 /**
@@ -278,11 +278,11 @@ cogl_is_bitmap (void *object);
 /**
  * COGL_BITMAP_ERROR:
  *
- * #GError domain for bitmap errors.
+ * #CoglError domain for bitmap errors.
  *
  * Since: 1.4
  */
-#define COGL_BITMAP_ERROR (cogl_bitmap_error_quark ())
+#define COGL_BITMAP_ERROR (cogl_bitmap_error_domain ())
 
 /**
  * CoglBitmapError:
@@ -305,7 +305,7 @@ typedef enum {
   COGL_BITMAP_ERROR_CORRUPT_IMAGE
 } CoglBitmapError;
 
-GQuark cogl_bitmap_error_quark (void);
+uint32_t cogl_bitmap_error_domain (void);
 
 G_END_DECLS
 
diff --git a/cogl/cogl-blend-string.c b/cogl/cogl-blend-string.c
index 5823a1d..afb9f14 100644
--- a/cogl/cogl-blend-string.c
+++ b/cogl/cogl-blend-string.c
@@ -37,6 +37,7 @@
 #include "cogl-context-private.h"
 #include "cogl-debug.h"
 #include "cogl-blend-string.h"
+#include "cogl-error-private.h"
 
 typedef enum _ParserState
 {
@@ -118,8 +119,8 @@ static CoglBlendStringFunctionInfo blend_functions[] = {
 
 #undef DEFINE_FUNCTION
 
-GQuark
-cogl_blend_string_error_quark (void)
+uint32_t
+cogl_blend_string_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-blend-string-error-quark");
 }
@@ -161,7 +162,7 @@ _cogl_blend_string_split_rgba_statement (CoglBlendStringStatement *statement,
 static CoglBool
 validate_tex_combine_statements (CoglBlendStringStatement *statements,
                                  int n_statements,
-                                 GError **error)
+                                 CoglError **error)
 {
   int i, j;
   const char *error_string;
@@ -190,11 +191,11 @@ validate_tex_combine_statements (CoglBlendStringStatement *statements,
   return TRUE;
 
 error:
-  g_set_error (error,
-               COGL_BLEND_STRING_ERROR,
-               detail,
-               "Invalid texture combine string: %s",
-               error_string);
+  _cogl_set_error (error,
+                   COGL_BLEND_STRING_ERROR,
+                   detail,
+                   "Invalid texture combine string: %s",
+                   error_string);
 
   if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
     {
@@ -207,7 +208,7 @@ error:
 static CoglBool
 validate_blend_statements (CoglBlendStringStatement *statements,
                            int n_statements,
-                           GError **error)
+                           CoglError **error)
 {
   int i, j;
   const char *error_string;
@@ -275,11 +276,11 @@ validate_blend_statements (CoglBlendStringStatement *statements,
   return TRUE;
 
 error:
-  g_set_error (error,
-               COGL_BLEND_STRING_ERROR,
-               detail,
-               "Invalid blend string: %s",
-               error_string);
+  _cogl_set_error (error,
+                   COGL_BLEND_STRING_ERROR,
+                   detail,
+                   "Invalid blend string: %s",
+                   error_string);
   return FALSE;
 }
 
@@ -287,7 +288,7 @@ static CoglBool
 validate_statements_for_context (CoglBlendStringStatement *statements,
                                  int n_statements,
                                  CoglBlendStringContext context,
-                                 GError **error)
+                                 CoglError **error)
 {
   const char *error_string;
 
@@ -313,13 +314,13 @@ validate_statements_for_context (CoglBlendStringStatement *statements,
     return validate_tex_combine_statements (statements, n_statements, error);
 
 error:
-  g_set_error (error,
-               COGL_BLEND_STRING_ERROR,
-               COGL_BLEND_STRING_ERROR_INVALID_ERROR,
-               "Invalid %s string: %s",
-               context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
-               "blend" : "texture combine",
-               error_string);
+  _cogl_set_error (error,
+                   COGL_BLEND_STRING_ERROR,
+                   COGL_BLEND_STRING_ERROR_INVALID_ERROR,
+                   "Invalid %s string: %s",
+                   context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
+                   "blend" : "texture combine",
+                   error_string);
 
   if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
     {
@@ -474,7 +475,7 @@ parse_argument (const char *string, /* original user string */
                 int current_arg,
                 CoglBlendStringArgument *arg, /* OUT */
                 CoglBlendStringContext context,
-                GError **error)
+                CoglError **error)
 {
   const char *p = *ret_p;
   const char *mark = NULL;
@@ -743,13 +744,13 @@ parse_argument (const char *string, /* original user string */
 error:
   {
     int offset = p - string;
-    g_set_error (error,
-                 COGL_BLEND_STRING_ERROR,
-                 COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR,
-                 "Syntax error for argument %d at offset %d: %s",
-                 current_arg,
-                 offset,
-                 error_string);
+    _cogl_set_error (error,
+                     COGL_BLEND_STRING_ERROR,
+                     COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR,
+                     "Syntax error for argument %d at offset %d: %s",
+                     current_arg,
+                     offset,
+                     error_string);
 
     if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
       {
@@ -764,7 +765,7 @@ int
 _cogl_blend_string_compile (const char *string,
                             CoglBlendStringContext context,
                             CoglBlendStringStatement *statements,
-                            GError **error)
+                            CoglError **error)
 {
   const char *p = string;
   const char *mark = NULL;
@@ -924,12 +925,12 @@ finished:
 error:
     {
       int offset = p - string;
-      g_set_error (error,
-                   COGL_BLEND_STRING_ERROR,
-                   COGL_BLEND_STRING_ERROR_PARSE_ERROR,
-                   "Syntax error at offset %d: %s",
-                   offset,
-                   error_string);
+      _cogl_set_error (error,
+                       COGL_BLEND_STRING_ERROR,
+                       COGL_BLEND_STRING_ERROR_PARSE_ERROR,
+                       "Syntax error at offset %d: %s",
+                       offset,
+                       error_string);
 
       if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
         {
@@ -981,7 +982,7 @@ _cogl_blend_string_test (void)
   };
   int i;
 
-  GError *error = NULL;
+  CoglError *error = NULL;
   for (i = 0; strings[i].string; i++)
     {
       CoglBlendStringStatement statements[2];
@@ -994,7 +995,7 @@ _cogl_blend_string_test (void)
           g_print ("Failed to parse string:\n%s\n%s\n",
                    strings[i].string,
                    error->message);
-          g_error_free (error);
+          cogl_error_free (error);
           error = NULL;
           continue;
         }
diff --git a/cogl/cogl-blend-string.h b/cogl/cogl-blend-string.h
index 75d2f95..10e6b29 100644
--- a/cogl/cogl-blend-string.h
+++ b/cogl/cogl-blend-string.h
@@ -126,7 +126,7 @@ CoglBool
 _cogl_blend_string_compile (const char *string,
                             CoglBlendStringContext context,
                             CoglBlendStringStatement *statements,
-                            GError **error);
+                            CoglError **error);
 
 void
 _cogl_blend_string_split_rgba_statement (CoglBlendStringStatement *statement,
diff --git a/cogl/cogl-context-private.h b/cogl/cogl-context-private.h
index 0be6000..67e2a1d 100644
--- a/cogl/cogl-context-private.h
+++ b/cogl/cogl-context-private.h
@@ -323,7 +323,7 @@ _cogl_context_get_winsys (CoglContext *context);
  * return FALSE and set @error */
 CoglBool
 _cogl_context_update_features (CoglContext *context,
-                               GError **error);
+                               CoglError **error);
 
 /* Obtains the context and returns retval if NULL */
 #define _COGL_GET_CONTEXT(ctxvar, retval) \
diff --git a/cogl/cogl-context.c b/cogl/cogl-context.c
index 4c959c7..c25818e 100644
--- a/cogl/cogl-context.c
+++ b/cogl/cogl-context.c
@@ -49,6 +49,7 @@
 #include "cogl1-context.h"
 #include "cogl-gpu-info-private.h"
 #include "cogl-config-private.h"
+#include "cogl-error-private.h"
 
 #include <string.h>
 
@@ -133,13 +134,14 @@ _cogl_context_get_winsys (CoglContext *context)
  */
 CoglContext *
 cogl_context_new (CoglDisplay *display,
-                  GError **error)
+                  CoglError **error)
 {
   CoglContext *context;
   GLubyte default_texture_data[] = { 0xff, 0xff, 0xff, 0x0 };
   CoglBitmap *default_texture_bitmap;
   const CoglWinsysVtable *winsys;
   int i;
+  CoglError *internal_error = NULL;
 
   _cogl_init ();
 
@@ -405,18 +407,26 @@ cogl_context_new (CoglDisplay *display,
                                      /* internal format */
                                      COGL_PIXEL_FORMAT_RGBA_8888_PRE,
                                      NULL);
-  /* If 3D or rectangle textures aren't supported then these should
-     just silently return NULL */
+
+  /* If 3D or rectangle textures aren't supported then these will
+   * return errors that we can simply ignore. */
+  internal_error = NULL;
   context->default_gl_texture_3d_tex =
     cogl_texture_3d_new_from_bitmap (default_texture_bitmap,
                                      1, /* height */
                                      1, /* depth */
                                      COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                     NULL);
+                                     &internal_error);
+  if (internal_error)
+    cogl_error_free (internal_error);
+
+  internal_error = NULL;
   context->default_gl_texture_rect_tex =
     cogl_texture_rectangle_new_from_bitmap (default_texture_bitmap,
                                             COGL_PIXEL_FORMAT_RGBA_8888_PRE,
-                                            NULL);
+                                            &internal_error);
+  if (internal_error)
+    cogl_error_free (internal_error);
 
   cogl_object_unref (default_texture_bitmap);
 
@@ -542,7 +552,7 @@ _cogl_context_free (CoglContext *context)
 CoglContext *
 _cogl_context_get_default (void)
 {
-  GError *error = NULL;
+  CoglError *error = NULL;
   /* Create if doesn't exist yet */
   if (_context == NULL)
     {
@@ -551,7 +561,7 @@ _cogl_context_get_default (void)
         {
           g_warning ("Failed to create default context: %s",
                      error->message);
-          g_error_free (error);
+          cogl_error_free (error);
         }
     }
 
@@ -579,7 +589,7 @@ cogl_egl_context_get_egl_display (CoglContext *context)
 
 CoglBool
 _cogl_context_update_features (CoglContext *context,
-                               GError **error)
+                               CoglError **error)
 {
   return context->driver_vtable->update_features (context, error);
 }
diff --git a/cogl/cogl-context.h b/cogl/cogl-context.h
index 17a04c9..980636b 100644
--- a/cogl/cogl-context.h
+++ b/cogl/cogl-context.h
@@ -73,7 +73,7 @@ G_BEGIN_DECLS
 /**
  * cogl_context_new:
  * @display: A #CoglDisplay pointer
- * @error: A GError return location.
+ * @error: A CoglError return location.
  *
  * Creates a new #CoglContext which acts as an application sandbox
  * for any state objects that are allocated.
@@ -84,7 +84,7 @@ G_BEGIN_DECLS
  */
 CoglContext *
 cogl_context_new (CoglDisplay *display,
-                  GError **error);
+                  CoglError **error);
 
 /**
  * cogl_context_get_display:
diff --git a/cogl/cogl-display.c b/cogl/cogl-display.c
index f6e01be..ec5f88a 100644
--- a/cogl/cogl-display.c
+++ b/cogl/cogl-display.c
@@ -83,7 +83,7 @@ cogl_display_new (CoglRenderer *renderer,
                   CoglOnscreenTemplate *onscreen_template)
 {
   CoglDisplay *display = g_slice_new0 (CoglDisplay);
-  GError *error = NULL;
+  CoglError *error = NULL;
 
   _cogl_init ();
 
@@ -119,7 +119,7 @@ cogl_display_get_renderer (CoglDisplay *display)
 
 CoglBool
 cogl_display_setup (CoglDisplay *display,
-                    GError **error)
+                    CoglError **error)
 {
   const CoglWinsysVtable *winsys;
 
diff --git a/cogl/cogl-display.h b/cogl/cogl-display.h
index c8cf7be..70bbf27 100644
--- a/cogl/cogl-display.h
+++ b/cogl/cogl-display.h
@@ -124,7 +124,7 @@ cogl_display_get_renderer (CoglDisplay *display);
 /**
  * cogl_display_setup:
  * @display: a #CoglDisplay
- * @error: return location for a #GError
+ * @error: return location for a #CoglError
  *
  * Explicitly sets up the given @display object. Use of this api is
  * optional since Cogl will internally setup the display if not done
@@ -154,7 +154,7 @@ cogl_display_get_renderer (CoglDisplay *display);
  */
 CoglBool
 cogl_display_setup (CoglDisplay *display,
-                    GError **error);
+                    CoglError **error);
 
 #ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
 /**
diff --git a/cogl/cogl-driver.h b/cogl/cogl-driver.h
index e22439a..65a944b 100644
--- a/cogl/cogl-driver.h
+++ b/cogl/cogl-driver.h
@@ -44,7 +44,7 @@ struct _CoglDriverVtable
 
   CoglBool
   (* update_features) (CoglContext *context,
-                       GError **error);
+                       CoglError **error);
 };
 
 #endif /* __COGL_DRIVER_H */
diff --git a/cogl/cogl-error-private.h b/cogl/cogl-error-private.h
new file mode 100644
index 0000000..85b64f7
--- /dev/null
+++ b/cogl/cogl-error-private.h
@@ -0,0 +1,48 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __COGL_ERROR_PRIVATE_H__
+#define __COGL_ERROR_PRIVATE_H__
+
+#include "cogl-error.h"
+
+void
+_cogl_set_error (CoglError **error,
+                 uint32_t domain,
+                 int code,
+                 const char *format,
+                 ...) G_GNUC_PRINTF (4, 5);
+
+void
+_cogl_set_error_literal (CoglError **error,
+                         uint32_t domain,
+                         int code,
+                         const char *message);
+
+void
+_cogl_propogate_gerror (CoglError **dest,
+                        GError *src);
+
+#define _cogl_clear_error(X) g_clear_error ((GError **)X)
+
+#endif /* __COGL_ERROR_PRIVATE_H__ */
diff --git a/cogl/cogl-error.c b/cogl/cogl-error.c
new file mode 100644
index 0000000..969c85c
--- /dev/null
+++ b/cogl/cogl-error.c
@@ -0,0 +1,109 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors:
+ *   Robert Bragg <robert linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cogl-types.h"
+#include "cogl-util.h"
+#include "cogl-error-private.h"
+
+#include <glib.h>
+
+void
+cogl_error_free (CoglError *error)
+{
+  g_error_free ((GError *)error);
+}
+
+CoglError *
+cogl_error_copy (CoglError *error)
+{
+  return (CoglError *)g_error_copy ((GError *)error);
+}
+
+CoglBool
+cogl_error_matches (CoglError *error,
+                    uint32_t domain,
+                    int code)
+{
+  return g_error_matches ((GError *)error, domain, code);
+}
+
+#define ERROR_OVERWRITTEN_WARNING \
+  "CoglError set over the top of a previous CoglError or " \
+  "uninitialized memory.\nThis indicates a bug in someone's " \
+  "code. You must ensure an error is NULL before it's set.\n" \
+  "The overwriting error message was: %s"
+
+void
+_cogl_set_error (CoglError **error,
+                 uint32_t domain,
+                 int code,
+                 const char *format,
+                 ...)
+{
+  GError *new;
+
+  va_list args;
+
+  va_start (args, format);
+
+  if (error == NULL)
+    {
+      g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
+      va_end (args);
+      return;
+    }
+
+  new = g_error_new_valist (domain, code, format, args);
+  va_end (args);
+
+  if (*error == NULL)
+    *error = (CoglError *)new;
+  else
+    g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
+}
+
+void
+_cogl_set_error_literal (CoglError **error,
+                         uint32_t domain,
+                         int code,
+                         const char *message)
+{
+  _cogl_set_error (error, domain, code, "%s", message);
+}
+
+void
+_cogl_propogate_gerror (CoglError **dest,
+                        GError *src)
+{
+  _COGL_RETURN_IF_FAIL (src != NULL);
+
+  _cogl_set_error_literal (dest, src->domain, src->code, src->message);
+  g_error_free (src);
+}
diff --git a/cogl/cogl-error.h b/cogl/cogl-error.h
new file mode 100644
index 0000000..2a7fcce
--- /dev/null
+++ b/cogl/cogl-error.h
@@ -0,0 +1,171 @@
+/*
+ * Cogl
+ *
+ * An object oriented GL/GLES Abstraction/Utility Layer
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(__COGL_H_INSIDE__) && !defined(COGL_COMPILATION)
+#error "Only <cogl/cogl.h> can be included directly."
+#endif
+
+#ifndef __COGL_ERROR_H__
+#define __COGL_ERROR_H__
+
+#include "cogl-types.h"
+
+/**
+ * SECTION:cogl-error
+ * @short_description: A way for Cogl to throw exceptions
+ *
+ * As a general rule Cogl shields non-recoverable errors from
+ * developers, such as most heap allocation failures (unless for
+ * exceptionally large resources which we might reasonably expect to
+ * fail) and this reduces the burdon on developers.
+ *
+ * There are some Cogl apis though that can fail for exceptional
+ * reasons that can also potentially be recovered from at runtime
+ * and for these apis we use a standard convention for reporting
+ * runtime recoverable errors.
+ *
+ * As an example if we look at the cogl_context_new() api which
+ * takes an error argument:
+ * |[
+ *   CoglContext *
+ *   cogl_context_new (CoglDisplay *display, CoglError **error);
+ * ]|
+ *
+ * A caller interested in catching any runtime error when creating a
+ * new #CoglContext would pass the address of a #CoglError pointer
+ * that has first been initialized to %NULL as follows:
+ *
+ * |[
+ *   CoglError *error = NULL;
+ *   CoglContext *context;
+ *
+ *   context = cogl_context_new (NULL, &error);
+ * ]|
+ *
+ * The return status should usually be enough to determine if there
+ * was an error set (in this example we can check if context == %NULL)
+ * but if it's not possible to tell from the function's return status
+ * you can instead look directly at the error pointer which you
+ * initialized to %NULL. In this example we now check the error,
+ * report any error to the user, free the error and then simply
+ * abort without attempting to recover.
+ *
+ * |[
+ *   if (context == NULL)
+ *     {
+ *       fprintf (stderr, "Failed to create a Cogl context: %s\n",
+ *                error->message);
+ *       cogl_error_free (error);
+ *       abort ();
+ *     }
+ * ]|
+ *
+ * All Cogl APIs that accept an error argument can also be passed a
+ * %NULL pointer. In this case if an exceptional error condition is hit
+ * then Cogl will simply log the error message and abort the
+ * application. This can be compared to language execeptions where the
+ * developer has not attempted to catch the exception. This means the
+ * above example is essentially redundant because it's what Cogl would
+ * have done automatically and so, similarly, if your application has
+ * no way to recover from a particular error you might just as well
+ * pass a %NULL #CoglError pointer to save a bit of typing.
+ *
+ * <note>If you are used to using the GLib API you will probably
+ * recognize that #CoglError is just like a #GError. In fact if Cogl
+ * has been built with --enable-glib then it is safe to cast a
+ * #CoglError to a #GError.</note>
+ *
+ * <note>An important detail to be aware of if you are used to using
+ * GLib's GError API is that Cogl deviates from the GLib GError
+ * conventions in one noteable way which is that a %NULL error pointer
+ * does not mean you want to ignore the details of an error, it means
+ * you are not trying to catch any exceptional errors the function might
+ * throw which will result in the program aborting with a log message
+ * if an error is thrown.</note>
+ */
+
+/**
+ * CoglError:
+ * @domain: A high-level domain identifier for the error
+ * @code: A specific error code within a specified domain
+ * @message: A human readable error message
+ */
+typedef struct _CoglError
+{
+  uint32_t domain;
+  int code;
+  char *message;
+} CoglError;
+
+/**
+ * cogl_error_free:
+ * @error: A #CoglError thrown by the Cogl api
+ *
+ * Frees a #CoglError and associated resources.
+ */
+void
+cogl_error_free (CoglError *error);
+
+/**
+ * cogl_error_copy:
+ * @error: A #CoglError thrown by the Cogl api
+ *
+ * Makes a copy of @error which can later be freed using
+ * cogl_error_free().
+ *
+ * Return value: A newly allocated #CoglError initialized to match the
+ *               contents of @error.
+ */
+CoglError *
+cogl_error_copy (CoglError *error);
+
+/**
+ * cogl_error_matches:
+ * @error: A #CoglError thrown by the Cogl api or %NULL
+ *
+ * Returns %TRUE if error matches domain and code, %FALSE otherwise.
+ * In particular, when error is %NULL, FALSE will be returned.
+ *
+ * Return value: whether the @error corresponds to the given @domain
+ *               and @code.
+ */
+CoglBool
+cogl_error_matches (CoglError *error,
+                    uint32_t domain,
+                    int code);
+
+/**
+ * COGL_GLIB_ERROR:
+ * @COGL_ERROR: A #CoglError thrown by the Cogl api or %NULL
+ *
+ * Simply casts a #CoglError to a #CoglError
+ *
+ * If Cogl is built with GLib support then it can safely be assumed
+ * that a CoglError is a GError and can be used directly with the
+ * GError api.
+ */
+#ifdef COGL_HAS_GLIB_SUPPORT
+#define COGL_GLIB_ERROR(COGL_ERROR) ((CoglError *)COGL_ERROR)
+#endif
+
+#endif /* __COGL_ERROR_H__ */
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index 2add6e6..405f31f 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -48,6 +48,7 @@
 #include "cogl-private.h"
 #include "cogl-primitives-private.h"
 #include "cogl-path-private.h"
+#include "cogl-error-private.h"
 
 #ifndef GL_FRAMEBUFFER
 #define GL_FRAMEBUFFER		0x8D40
@@ -135,8 +136,8 @@ COGL_OBJECT_DEFINE_WITH_CODE (Offscreen, offscreen,
  * abstract class manually.
  */
 
-GQuark
-cogl_framebuffer_error_quark (void)
+uint32_t
+cogl_framebuffer_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-framebuffer-error-quark");
 }
@@ -1032,7 +1033,7 @@ _cogl_framebuffer_try_creating_gl_fbo (CoglContext *ctx,
 
 static CoglBool
 _cogl_offscreen_allocate (CoglOffscreen *offscreen,
-                          GError **error)
+                          CoglError **error)
 {
   CoglFramebuffer *fb = COGL_FRAMEBUFFER (offscreen);
   CoglContext *ctx = fb->context;
@@ -1149,16 +1150,16 @@ _cogl_offscreen_allocate (CoglOffscreen *offscreen,
     }
   else
     {
-      g_set_error (error, COGL_FRAMEBUFFER_ERROR,
-                   COGL_FRAMEBUFFER_ERROR_ALLOCATE,
-                   "Failed to create an OpenGL framebuffer object");
+      _cogl_set_error (error, COGL_FRAMEBUFFER_ERROR,
+                       COGL_FRAMEBUFFER_ERROR_ALLOCATE,
+                       "Failed to create an OpenGL framebuffer object");
       return FALSE;
     }
 }
 
 CoglBool
 cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
-                           GError **error)
+                           CoglError **error)
 {
   CoglOnscreen *onscreen = COGL_ONSCREEN (framebuffer);
   const CoglWinsysVtable *winsys = _cogl_framebuffer_get_winsys (framebuffer);
diff --git a/cogl/cogl-framebuffer.h b/cogl/cogl-framebuffer.h
index 6869be7..1ea2aee 100644
--- a/cogl/cogl-framebuffer.h
+++ b/cogl/cogl-framebuffer.h
@@ -89,7 +89,7 @@ typedef struct _CoglFramebuffer CoglFramebuffer;
 /**
  * cogl_framebuffer_allocate:
  * @framebuffer: A #CoglFramebuffer
- * @error: A pointer to a #GError for returning exceptions.
+ * @error: A pointer to a #CoglError for returning exceptions.
  *
  * Explicitly allocates a configured #CoglFramebuffer allowing developers to
  * check and handle any errors that might arise from an unsupported
@@ -108,7 +108,7 @@ typedef struct _CoglFramebuffer CoglFramebuffer;
  */
 CoglBool
 cogl_framebuffer_allocate (CoglFramebuffer *framebuffer,
-                           GError **error);
+                           CoglError **error);
 
 /**
  * cogl_framebuffer_get_width:
@@ -1689,15 +1689,15 @@ cogl_framebuffer_read_pixels (CoglFramebuffer *framebuffer,
 CoglFramebuffer *
 cogl_get_draw_framebuffer (void);
 
-GQuark
-cogl_framebuffer_error_quark (void);
+uint32_t
+cogl_framebuffer_error_domain (void);
 
 /**
  * COGL_FRAMEBUFFER_ERROR:
  *
  * An error domain for reporting #CoglFramebuffer exceptions
  */
-#define COGL_FRAMEBUFFER_ERROR (cogl_framebuffer_error_quark ())
+#define COGL_FRAMEBUFFER_ERROR (cogl_framebuffer_error_domain ())
 
 typedef enum { /*< prefix=COGL_FRAMEBUFFER_ERROR >*/
   COGL_FRAMEBUFFER_ERROR_ALLOCATE
diff --git a/cogl/cogl-gles2-context.c b/cogl/cogl-gles2-context.c
index 3585705..cf8e921 100644
--- a/cogl/cogl-gles2-context.c
+++ b/cogl/cogl-gles2-context.c
@@ -44,6 +44,7 @@
 #include "cogl-swap-chain-private.h"
 #include "cogl-texture-2d-private.h"
 #include "cogl-pipeline-opengl-private.h"
+#include "cogl-error-private.h"
 
 static void _cogl_gles2_context_free (CoglGLES2Context *gles2_context);
 
@@ -83,8 +84,8 @@ enum {
   RESTORE_FB_FROM_ONSCREEN,
 };
 
-GQuark
-_cogl_gles2_context_error_quark (void)
+uint32_t
+_cogl_gles2_context_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-gles2-context-error-quark");
 }
@@ -1585,14 +1586,14 @@ create_wrapper_shader (CoglContext *ctx)
 }
 
 CoglGLES2Context *
-cogl_gles2_context_new (CoglContext *ctx, GError **error)
+cogl_gles2_context_new (CoglContext *ctx, CoglError **error)
 {
   CoglGLES2Context *gles2_ctx;
   const CoglWinsysVtable *winsys;
 
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_GLES2_CONTEXT))
     {
-      g_set_error (error, COGL_GLES2_CONTEXT_ERROR,
+      _cogl_set_error (error, COGL_GLES2_CONTEXT_ERROR,
                    COGL_GLES2_CONTEXT_ERROR_UNSUPPORTED,
                    "Backend doesn't support creating GLES2 contexts");
 
@@ -1716,11 +1717,11 @@ cogl_gles2_context_get_vtable (CoglGLES2Context *gles2_ctx)
 static CoglGLES2Offscreen *
 _cogl_gles2_offscreen_allocate (CoglOffscreen *offscreen,
                                 CoglGLES2Context *gles2_context,
-                                GError **error)
+                                CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (offscreen);
   const CoglWinsysVtable *winsys;
-  GError *internal_error = NULL;
+  CoglError *internal_error = NULL;
   CoglGLES2Offscreen *gles2_offscreen;
 
   if (!framebuffer->allocated &&
@@ -1743,8 +1744,8 @@ _cogl_gles2_offscreen_allocate (CoglOffscreen *offscreen,
     {
       winsys->restore_context (framebuffer->context);
 
-      g_error_free (internal_error);
-      g_set_error (error, COGL_FRAMEBUFFER_ERROR,
+      cogl_error_free (internal_error);
+      _cogl_set_error (error, COGL_FRAMEBUFFER_ERROR,
                    COGL_FRAMEBUFFER_ERROR_ALLOCATE,
                    "Failed to bind gles2 context to create framebuffer");
       return NULL;
@@ -1764,7 +1765,7 @@ _cogl_gles2_offscreen_allocate (CoglOffscreen *offscreen,
 
       g_slice_free (CoglGLES2Offscreen, gles2_offscreen);
 
-      g_set_error (error, COGL_FRAMEBUFFER_ERROR,
+      _cogl_set_error (error, COGL_FRAMEBUFFER_ERROR,
                    COGL_FRAMEBUFFER_ERROR_ALLOCATE,
                    "Failed to create an OpenGL framebuffer object");
       return NULL;
@@ -1795,10 +1796,10 @@ cogl_push_gles2_context (CoglContext *ctx,
                          CoglGLES2Context *gles2_ctx,
                          CoglFramebuffer *read_buffer,
                          CoglFramebuffer *write_buffer,
-                         GError **error)
+                         CoglError **error)
 {
   const CoglWinsysVtable *winsys = ctx->display->renderer->winsys_vtable;
-  GError *internal_error = NULL;
+  CoglError *internal_error = NULL;
 
   _COGL_RETURN_VAL_IF_FAIL (gles2_ctx != NULL, FALSE);
 
@@ -1877,8 +1878,8 @@ cogl_push_gles2_context (CoglContext *ctx,
     {
       winsys->restore_context (ctx);
 
-      g_error_free (internal_error);
-      g_set_error (error, COGL_GLES2_CONTEXT_ERROR,
+      cogl_error_free (internal_error);
+      _cogl_set_error (error, COGL_GLES2_CONTEXT_ERROR,
                    COGL_GLES2_CONTEXT_ERROR_DRIVER,
                    "Driver failed to make GLES2 context current");
       return FALSE;
@@ -1962,7 +1963,7 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
                                        int width,
                                        int height,
                                        CoglPixelFormat internal_format,
-                                       GError **error)
+                                       CoglError **error)
 {
   return cogl_texture_2d_new_from_foreign (ctx,
                                            handle,
diff --git a/cogl/cogl-gles2.h b/cogl/cogl-gles2.h
index 34467b2..cbcea8b 100644
--- a/cogl/cogl-gles2.h
+++ b/cogl/cogl-gles2.h
@@ -124,8 +124,8 @@ struct _CoglGLES2Vtable
 #undef COGL_EXT_END
 };
 
-GQuark
-_cogl_gles2_context_error_quark (void);
+uint32_t
+_cogl_gles2_context_error_domain (void);
 
 /**
  * COGL_GLES2_CONTEXT_ERROR:
@@ -136,7 +136,7 @@ _cogl_gles2_context_error_quark (void);
  * Since: 2.0
  * Stability: unstable
  */
-#define COGL_GLES2_CONTEXT_ERROR (_cogl_gles2_context_error_quark ())
+#define COGL_GLES2_CONTEXT_ERROR (_cogl_gles2_context_error_domain ())
 
 /**
  * CoglGLES2ContextError:
@@ -156,7 +156,7 @@ typedef enum { /*< prefix=COGL_GLES2_CONTEXT_ERROR >*/
 /**
  * cogl_gles2_context_new:
  * @ctx: A #CoglContext
- * @error: A pointer to a #GError for returning exceptions
+ * @error: A pointer to a #CoglError for returning exceptions
  *
  * Allocates a new OpenGLES 2.0 context that can be used to render to
  * #CoglOffscreen framebuffers (Rendering to #CoglOnscreen
@@ -183,7 +183,7 @@ typedef enum { /*< prefix=COGL_GLES2_CONTEXT_ERROR >*/
  * Stability: unstable
  */
 CoglGLES2Context *
-cogl_gles2_context_new (CoglContext *ctx, GError **error);
+cogl_gles2_context_new (CoglContext *ctx, CoglError **error);
 
 /**
  * cogl_gles2_context_get_vtable:
@@ -215,7 +215,7 @@ cogl_gles2_context_get_vtable (CoglGLES2Context *gles2_ctx);
  * @write_buffer: A #CoglFramebuffer to access for drawing operations
  *                such as glDrawArrays. (must be a #CoglOffscreen
  *               framebuffer currently)
- * @error: A pointer to a #GError for returning exceptions
+ * @error: A pointer to a #CoglError for returning exceptions
  *
  * Pushes the given @gles2_ctx onto a stack associated with @ctx so
  * that the OpenGLES 2.0 api can be used instead of the Cogl
@@ -239,7 +239,7 @@ cogl_push_gles2_context (CoglContext *ctx,
                          CoglGLES2Context *gles2_ctx,
                          CoglFramebuffer *read_buffer,
                          CoglFramebuffer *write_buffer,
-                         GError **error);
+                         CoglError **error);
 
 /**
  * cogl_pop_gles2_context:
@@ -306,7 +306,7 @@ cogl_gles2_texture_2d_new_from_handle (CoglContext *ctx,
                                        int width,
                                        int height,
                                        CoglPixelFormat internal_format,
-                                       GError **error);
+                                       CoglError **error);
 
 /**
  * cogl_gles2_texture_get_handle:
diff --git a/cogl/cogl-internal.h b/cogl/cogl-internal.h
index 5881315..2d6e089 100644
--- a/cogl/cogl-internal.h
+++ b/cogl/cogl-internal.h
@@ -82,7 +82,7 @@ _cogl_transform_point (const CoglMatrix *matrix_mv,
                        float *x,
                        float *y);
 
-#define COGL_DRIVER_ERROR (_cogl_driver_error_quark ())
+#define COGL_DRIVER_ERROR (_cogl_driver_error_domain ())
 
 typedef enum { /*< prefix=COGL_DRIVER_ERROR >*/
   COGL_DRIVER_ERROR_UNKNOWN_VERSION,
@@ -118,7 +118,7 @@ typedef enum _CoglPipelineEvalFlags
 CoglBool
 _cogl_check_extension (const char *name, const char *ext);
 
-GQuark
-_cogl_driver_error_quark (void);
+uint32_t
+_cogl_driver_error_domain (void);
 
 #endif /* __COGL_INTERNAL_H */
diff --git a/cogl/cogl-pipeline-layer-state.c b/cogl/cogl-pipeline-layer-state.c
index 19bece5..b69ff46 100644
--- a/cogl/cogl-pipeline-layer-state.c
+++ b/cogl/cogl-pipeline-layer-state.c
@@ -37,6 +37,7 @@
 #include "cogl-snippet-private.h"
 #include "cogl-texture-private.h"
 #include "cogl-pipeline-layer-state-private.h"
+#include "cogl-error-private.h"
 
 #include "string.h"
 #if 0
@@ -734,7 +735,7 @@ CoglBool
 cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
                                                      int layer_index,
                                                      CoglBool enable,
-                                                     GError **error)
+                                                     CoglError **error)
 {
   CoglPipelineLayerState       change =
     COGL_PIPELINE_LAYER_STATE_POINT_SPRITE_COORDS;
@@ -752,9 +753,11 @@ cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
     {
       if (error)
         {
-          g_set_error (error, COGL_ERROR, COGL_ERROR_UNSUPPORTED,
-                       "Point sprite texture coordinates are enabled "
-                       "for a layer but the GL driver does not support it.");
+          _cogl_set_error (error,
+                           COGL_SYSTEM_ERROR,
+                           COGL_SYSTEM_ERROR_UNSUPPORTED,
+                           "Point sprite texture coordinates are enabled for "
+                           "a layer but the GL driver does not support it.");
         }
       else
         {
@@ -1168,7 +1171,7 @@ CoglBool
 cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
 				 int layer_index,
 				 const char *combine_description,
-                                 GError **error)
+                                 CoglError **error)
 {
   CoglPipelineLayerState state = COGL_PIPELINE_LAYER_STATE_COMBINE;
   CoglPipelineLayer *authority;
@@ -1177,7 +1180,6 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
   CoglBlendStringStatement split[2];
   CoglBlendStringStatement *rgb;
   CoglBlendStringStatement *a;
-  GError *internal_error = NULL;
   int count;
 
   _COGL_RETURN_VAL_IF_FAIL (cogl_is_pipeline (pipeline), FALSE);
@@ -1198,19 +1200,9 @@ cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
     _cogl_blend_string_compile (combine_description,
                                 COGL_BLEND_STRING_CONTEXT_TEXTURE_COMBINE,
                                 statements,
-                                &internal_error);
+                                error);
   if (!count)
-    {
-      if (error)
-	g_propagate_error (error, internal_error);
-      else
-	{
-	  g_warning ("Cannot compile combine description: %s\n",
-		     internal_error->message);
-	  g_error_free (internal_error);
-	}
-      return FALSE;
-    }
+    return FALSE;
 
   if (statements[0].mask == COGL_BLEND_STRING_CHANNEL_MASK_RGBA)
     {
diff --git a/cogl/cogl-pipeline-layer-state.h b/cogl/cogl-pipeline-layer-state.h
index 66eeb4e..a785411 100644
--- a/cogl/cogl-pipeline-layer-state.h
+++ b/cogl/cogl-pipeline-layer-state.h
@@ -206,7 +206,7 @@ cogl_pipeline_remove_layer (CoglPipeline *pipeline,
  * @layer_index: Specifies the layer you want define a combine function for
  * @blend_string: A <link linkend="cogl-Blend-Strings">Cogl blend string</link>
  *    describing the desired texture combine function.
- * @error: A #GError that may report parse errors or lack of GPU/driver
+ * @error: A #CoglError that may report parse errors or lack of GPU/driver
  *   support. May be %NULL, in which case a warning will be printed out if an
  *   error is encountered.
  *
@@ -297,7 +297,7 @@ CoglBool
 cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
 				 int           layer_index,
 				 const char   *blend_string,
-                                 GError      **error);
+                                 CoglError      **error);
 
 /**
  * cogl_pipeline_set_layer_combine_constant:
@@ -414,7 +414,7 @@ cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
  * @pipeline: A #CoglPipeline object
  * @layer_index: the layer number to change.
  * @enable: whether to enable point sprite coord generation.
- * @error: A return location for a GError, or NULL to ignore errors.
+ * @error: A return location for a CoglError, or NULL to ignore errors.
  *
  * When rendering points, if @enable is %TRUE then the texture
  * coordinates for this layer will be replaced with coordinates that
@@ -435,7 +435,7 @@ CoglBool
 cogl_pipeline_set_layer_point_sprite_coords_enabled (CoglPipeline *pipeline,
                                                      int           layer_index,
                                                      CoglBool      enable,
-                                                     GError      **error);
+                                                     CoglError      **error);
 
 /**
  * cogl_pipeline_get_layer_point_sprite_coords_enabled:
diff --git a/cogl/cogl-pipeline-state.c b/cogl/cogl-pipeline-state.c
index b8e53dc..fddc6c9 100644
--- a/cogl/cogl-pipeline-state.c
+++ b/cogl/cogl-pipeline-state.c
@@ -36,6 +36,7 @@
 #include "cogl-depth-state-private.h"
 #include "cogl-pipeline-state-private.h"
 #include "cogl-snippet-private.h"
+#include "cogl-error-private.h"
 
 #include "string.h"
 
@@ -609,14 +610,13 @@ setup_blend_state (CoglBlendStringStatement *statement,
 CoglBool
 cogl_pipeline_set_blend (CoglPipeline *pipeline,
                          const char *blend_description,
-                         GError **error)
+                         CoglError **error)
 {
   CoglPipelineState state = COGL_PIPELINE_STATE_BLEND;
   CoglPipeline *authority;
   CoglBlendStringStatement statements[2];
   CoglBlendStringStatement *rgb;
   CoglBlendStringStatement *a;
-  GError *internal_error = NULL;
   int count;
   CoglPipelineBlendState *blend_state;
 
@@ -628,19 +628,9 @@ cogl_pipeline_set_blend (CoglPipeline *pipeline,
     _cogl_blend_string_compile (blend_description,
                                 COGL_BLEND_STRING_CONTEXT_BLENDING,
                                 statements,
-                                &internal_error);
+                                error);
   if (!count)
-    {
-      if (error)
-	g_propagate_error (error, internal_error);
-      else
-	{
-	  g_warning ("Cannot compile blend description: %s\n",
-		     internal_error->message);
-	  g_error_free (internal_error);
-	}
-      return FALSE;
-    }
+    return FALSE;
 
   if (count == 1)
     rgb = a = statements;
@@ -754,7 +744,7 @@ cogl_pipeline_set_blend_constant (CoglPipeline *pipeline,
 CoglBool
 cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
                                const CoglDepthState *depth_state,
-                               GError **error)
+                               CoglError **error)
 {
   CoglPipelineState state = COGL_PIPELINE_STATE_DEPTH;
   CoglPipeline *authority;
@@ -779,10 +769,10 @@ cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
       (depth_state->range_near != 0 ||
        depth_state->range_far != 1))
     {
-      g_set_error (error,
-                   COGL_ERROR,
-                   COGL_ERROR_UNSUPPORTED,
-                   "glDepthRange not available on GLES 1");
+      _cogl_set_error (error,
+                       COGL_SYSTEM_ERROR,
+                       COGL_SYSTEM_ERROR_UNSUPPORTED,
+                       "glDepthRange not available on GLES 1");
       return FALSE;
     }
 
diff --git a/cogl/cogl-pipeline-state.h b/cogl/cogl-pipeline-state.h
index 02f4a92..c402e6d 100644
--- a/cogl/cogl-pipeline-state.h
+++ b/cogl/cogl-pipeline-state.h
@@ -200,7 +200,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline);
  * @pipeline: A #CoglPipeline object
  * @blend_string: A <link linkend="cogl-Blend-Strings">Cogl blend string</link>
  *   describing the desired blend function.
- * @error: return location for a #GError that may report lack of driver
+ * @error: return location for a #CoglError that may report lack of driver
  *   support if you give separate blend string statements for the alpha
  *   channel and RGB channels since some drivers, or backends such as
  *   GLES 1.1, don't support this feature. May be %NULL, in which case a
@@ -280,7 +280,7 @@ cogl_pipeline_get_alpha_test_reference (CoglPipeline *pipeline);
 CoglBool
 cogl_pipeline_set_blend (CoglPipeline *pipeline,
                          const char   *blend_string,
-                         GError      **error);
+                         CoglError      **error);
 
 /**
  * cogl_pipeline_set_blend_constant:
@@ -368,7 +368,7 @@ cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
  * cogl_pipeline_set_depth_state:
  * @pipeline: A #CoglPipeline object
  * @state: A #CoglDepthState struct
- * @error: A #GError to report failures to setup the given @state.
+ * @error: A #CoglError to report failures to setup the given @state.
  *
  * This commits all the depth state configured in @state struct to the
  * given @pipeline. The configuration values are copied into the
@@ -387,7 +387,7 @@ cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
 CoglBool
 cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
                                const CoglDepthState *state,
-                               GError **error);
+                               CoglError **error);
 
 /**
  * cogl_pipeline_get_depth_state
diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c
index d47e972..83d653b 100644
--- a/cogl/cogl-renderer.c
+++ b/cogl/cogl-renderer.c
@@ -43,6 +43,7 @@
 #include "cogl-winsys-private.h"
 #include "cogl-winsys-stub-private.h"
 #include "cogl-config-private.h"
+#include "cogl-error-private.h"
 
 #ifdef COGL_HAS_EGL_PLATFORM_XLIB_SUPPORT
 #include "cogl-winsys-egl-x11-private.h"
@@ -120,8 +121,8 @@ typedef struct _CoglNativeFilterClosure
   void *data;
 } CoglNativeFilterClosure;
 
-GQuark
-cogl_renderer_error_quark (void)
+uint32_t
+cogl_renderer_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-renderer-error-quark");
 }
@@ -216,7 +217,7 @@ cogl_xlib_renderer_set_event_retrieval_enabled (CoglRenderer *renderer,
 CoglBool
 cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
                                        CoglOnscreenTemplate *onscreen_template,
-                                       GError **error)
+                                       CoglError **error)
 {
   CoglDisplay *display;
 
@@ -237,7 +238,7 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
 
 static CoglBool
 _cogl_renderer_choose_driver (CoglRenderer *renderer,
-                              GError **error)
+                              CoglError **error)
 {
   const char *driver_name = g_getenv ("COGL_DRIVER");
   const char *libgl_name;
@@ -298,7 +299,7 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer,
     }
 #endif
 
-  g_set_error (error,
+  _cogl_set_error (error,
                COGL_DRIVER_ERROR,
                COGL_DRIVER_ERROR_NO_SUITABLE_DRIVER_FOUND,
                "No suitable driver found");
@@ -309,7 +310,7 @@ found:
   if (support_gles2_constraint &&
       renderer->driver != COGL_DRIVER_GLES2)
     {
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_RENDERER_ERROR,
                    COGL_RENDERER_ERROR_BAD_CONSTRAINT,
                    "No suitable driver found");
@@ -323,7 +324,7 @@ found:
 
   if (renderer->libgl_module == NULL)
     {
-      g_set_error (error, COGL_DRIVER_ERROR,
+      _cogl_set_error (error, COGL_DRIVER_ERROR,
                    COGL_DRIVER_ERROR_FAILED_TO_LOAD_LIBRARY,
                    "Failed to dynamically open the GL library \"%s\"",
                    libgl_name);
@@ -338,7 +339,7 @@ found:
 /* Final connection API */
 
 CoglBool
-cogl_renderer_connect (CoglRenderer *renderer, GError **error)
+cogl_renderer_connect (CoglRenderer *renderer, CoglError **error)
 {
   int i;
   GString *error_message;
@@ -357,7 +358,7 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
   for (i = 0; i < G_N_ELEMENTS (_cogl_winsys_vtable_getters); i++)
     {
       const CoglWinsysVtable *winsys = _cogl_winsys_vtable_getters[i]();
-      GError *tmp_error = NULL;
+      CoglError *tmp_error = NULL;
       GList *l;
       CoglBool skip_due_to_constraints = FALSE;
 
@@ -400,7 +401,7 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
         {
           g_string_append_c (error_message, '\n');
           g_string_append (error_message, tmp_error->message);
-          g_error_free (tmp_error);
+          cogl_error_free (tmp_error);
         }
       else
         {
@@ -414,14 +415,14 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error)
     {
       if (constraints_failed)
         {
-          g_set_error (error, COGL_RENDERER_ERROR,
+          _cogl_set_error (error, COGL_RENDERER_ERROR,
                        COGL_RENDERER_ERROR_BAD_CONSTRAINT,
                        "Failed to connected to any renderer due to constraints");
           return FALSE;
         }
 
       renderer->winsys_vtable = NULL;
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Failed to connected to any renderer: %s",
                    error_message->str);
diff --git a/cogl/cogl-renderer.h b/cogl/cogl-renderer.h
index c8bac6e..1af246a 100644
--- a/cogl/cogl-renderer.h
+++ b/cogl/cogl-renderer.h
@@ -32,6 +32,7 @@
 
 #include <cogl/cogl-types.h>
 #include <cogl/cogl-onscreen-template.h>
+#include <cogl/cogl-error.h>
 
 G_BEGIN_DECLS
 
@@ -73,10 +74,10 @@ G_BEGIN_DECLS
  *
  * An error domain for exceptions reported by Cogl
  */
-#define COGL_RENDERER_ERROR cogl_renderer_error_quark ()
+#define COGL_RENDERER_ERROR cogl_renderer_error_domain ()
 
-GQuark
-cogl_renderer_error_quark (void);
+uint32_t
+cogl_renderer_error_domain (void);
 
 typedef struct _CoglRenderer CoglRenderer;
 
@@ -220,7 +221,7 @@ cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer);
  * cogl_renderer_check_onscreen_template:
  * @renderer: A #CoglRenderer
  * @onscreen_template: A #CoglOnscreenTemplate
- * @error: A pointer to a #GError for reporting exceptions
+ * @error: A pointer to a #CoglError for reporting exceptions
  *
  * Tests if a given @onscreen_template can be supported with the given
  * @renderer.
@@ -233,14 +234,14 @@ cogl_renderer_get_n_fragment_texture_units (CoglRenderer *renderer);
 CoglBool
 cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
                                        CoglOnscreenTemplate *onscreen_template,
-                                       GError **error);
+                                       CoglError **error);
 
 /* Final connection API */
 
 /**
  * cogl_renderer_connect:
  * @renderer: An unconnected #CoglRenderer
- * @error a pointer to a #GError for reporting exceptions
+ * @error a pointer to a #CoglError for reporting exceptions
  *
  * Connects the configured @renderer. Renderer connection isn't a
  * very active process, it basically just means validating that
@@ -253,7 +254,7 @@ cogl_renderer_check_onscreen_template (CoglRenderer *renderer,
  * Stability: unstable
  */
 CoglBool
-cogl_renderer_connect (CoglRenderer *renderer, GError **error);
+cogl_renderer_connect (CoglRenderer *renderer, CoglError **error);
 
 /**
  * CoglRendererConstraint:
diff --git a/cogl/cogl-sdl.c b/cogl/cogl-sdl.c
index c4adbf8..03afeb7 100644
--- a/cogl/cogl-sdl.c
+++ b/cogl/cogl-sdl.c
@@ -46,7 +46,7 @@ cogl_sdl_renderer_get_event_type (CoglRenderer *renderer)
 }
 
 CoglContext *
-cogl_sdl_context_new (int type, GError **error)
+cogl_sdl_context_new (int type, CoglError **error)
 {
   CoglRenderer *renderer = cogl_renderer_new ();
   CoglDisplay *display;
diff --git a/cogl/cogl-sdl.h b/cogl/cogl-sdl.h
index 732beaf..cf7f9c7 100644
--- a/cogl/cogl-sdl.h
+++ b/cogl/cogl-sdl.h
@@ -47,7 +47,7 @@ G_BEGIN_DECLS
  * this:
  * |[
  * MyAppData data;
- * GError *error = NULL;
+ * CoglError *error = NULL;
  *
  * data.ctx = cogl_sdl_context_new (SDL_USEREVENT, &error);
  * if (!data.ctx)
@@ -90,7 +90,7 @@ G_BEGIN_DECLS
  * cogl_sdl_context_new:
  * @type: An SDL user event type between %SDL_USEREVENT and
  *        %SDL_NUMEVENTS - %1
- * @error: A GError return location.
+ * @error: A CoglError return location.
  *
  * This is a convenience function for creating a new #CoglContext for
  * use with SDL and specifying what SDL user event type Cogl can use
@@ -123,7 +123,7 @@ G_BEGIN_DECLS
  * Stability: unstable
  */
 CoglContext *
-cogl_sdl_context_new (int type, GError **error);
+cogl_sdl_context_new (int type, CoglError **error);
 
 /**
  * cogl_sdl_renderer_set_event_type:
diff --git a/cogl/cogl-texture-2d-private.h b/cogl/cogl-texture-2d-private.h
index 823303c..a7f41b6 100644
--- a/cogl/cogl-texture-2d-private.h
+++ b/cogl/cogl-texture-2d-private.h
@@ -67,7 +67,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
                                      int height,
                                      CoglPixelFormat format,
                                      EGLImageKHR image,
-                                     GError **error);
+                                     CoglError **error);
 #endif
 
 /*
diff --git a/cogl/cogl-texture-2d-sliced.c b/cogl/cogl-texture-2d-sliced.c
index fc33abe..24a7487 100644
--- a/cogl/cogl-texture-2d-sliced.c
+++ b/cogl/cogl-texture-2d-sliced.c
@@ -45,6 +45,7 @@
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-primitive-texture.h"
+#include "cogl-error-private.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -753,7 +754,7 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
 
       for (x = 0; x < n_x_slices; ++x)
         {
-          GError *error = NULL;
+          CoglError *error = NULL;
           x_span = &g_array_index (tex_2ds->slice_x_spans, CoglSpan, x);
 
           COGL_NOTE (SLICING, "CREATE SLICE (%d,%d)\tsize (%d,%d)",
@@ -767,7 +768,7 @@ _cogl_texture_2d_sliced_slices_create (CoglContext *ctx,
           if (!slice_textures[y * n_x_slices + x])
             {
               g_array_set_size (tex_2ds->slice_textures, y * n_x_slices + x);
-              g_error_free (error);
+              cogl_error_free (error);
               return FALSE;
             }
         }
@@ -844,7 +845,7 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
                                       unsigned int height,
                                       int max_waste,
                                       CoglPixelFormat internal_format,
-                                      GError **error)
+                                      CoglError **error)
 {
   CoglTexture2DSliced   *tex_2ds;
 
@@ -863,10 +864,10 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
                                           internal_format))
     {
       _cogl_texture_2d_sliced_free (tex_2ds);
-      g_set_error (error,
-                   COGL_ERROR,
-                   COGL_ERROR_NO_MEMORY,
-                   "Not enough memory to allocate texture slices");
+      _cogl_set_error (error,
+                       COGL_SYSTEM_ERROR,
+                       COGL_SYSTEM_ERROR_NO_MEMORY,
+                       "Not enough memory to allocate texture slices");
       return NULL;
     }
 
diff --git a/cogl/cogl-texture-2d-sliced.h b/cogl/cogl-texture-2d-sliced.h
index 7ec2fed..3173d14 100644
--- a/cogl/cogl-texture-2d-sliced.h
+++ b/cogl/cogl-texture-2d-sliced.h
@@ -75,7 +75,7 @@ typedef struct _CoglTexture2DSliced CoglTexture2DSliced;
  *             are allowed in the non-power-of-two textures before
  *             they must be sliced to reduce the amount of waste.
  * @internal_format: The format of the texture
- * @error: A #GError for exceptions.
+ * @error: A #CoglError for exceptions.
  *
  * Creates a #CoglTexture2DSliced that may internally be comprised of
  * 1 or more #CoglTexture2D textures with power-of-two sizes.
@@ -97,7 +97,7 @@ cogl_texture_2d_sliced_new_with_size (CoglContext *ctx,
                                       unsigned int height,
                                       int max_waste,
                                       CoglPixelFormat internal_format,
-                                      GError **error);
+                                      CoglError **error);
 
 /**
  * cogl_is_texture_2d_sliced:
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index 8ea4c75..1853dda 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -38,6 +38,7 @@
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-framebuffer-private.h"
+#include "cogl-error-private.h"
 #ifdef COGL_HAS_EGL_SUPPORT
 #include "cogl-winsys-egl-private.h"
 #endif
@@ -184,7 +185,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
                                int width,
                                int height,
                                CoglPixelFormat internal_format,
-                               GError **error)
+                               CoglError **error)
 {
   CoglTexture2D         *tex_2d;
   GLenum                 gl_intformat;
@@ -197,10 +198,10 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
 
   if (!_cogl_texture_2d_can_create (width, height, internal_format))
     {
-      g_set_error (error, COGL_TEXTURE_ERROR,
-                   COGL_TEXTURE_ERROR_SIZE,
-                   "Failed to create texture 2d due to size/format"
-                   " constraints");
+      _cogl_set_error (error, COGL_TEXTURE_ERROR,
+                       COGL_TEXTURE_ERROR_SIZE,
+                       "Failed to create texture 2d due to size/format"
+                       " constraints");
       return NULL;
     }
 
@@ -226,7 +227,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
 CoglTexture2D *
 cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
                                  CoglPixelFormat internal_format,
-                                 GError **error)
+                                 CoglError **error)
 {
   CoglTexture2D *tex_2d;
   CoglBitmap *dst_bmp;
@@ -248,10 +249,10 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
                                     cogl_bitmap_get_height (bmp),
                                     internal_format))
     {
-      g_set_error (error, COGL_TEXTURE_ERROR,
-                   COGL_TEXTURE_ERROR_SIZE,
-                   "Failed to create texture 2d due to size/format"
-                   " constraints");
+      _cogl_set_error (error, COGL_TEXTURE_ERROR,
+                       COGL_TEXTURE_ERROR_SIZE,
+                       "Failed to create texture 2d due to size/format"
+                       " constraints");
       return NULL;
 
     }
@@ -263,9 +264,9 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bmp,
                                                    &gl_format,
                                                    &gl_type)) == NULL)
     {
-      g_set_error (error, COGL_TEXTURE_ERROR,
-                   COGL_TEXTURE_ERROR_FORMAT,
-                   "Failed to prepare texture upload due to format");
+      _cogl_set_error (error, COGL_TEXTURE_ERROR,
+                       COGL_TEXTURE_ERROR_FORMAT,
+                       "Failed to prepare texture upload due to format");
       return NULL;
     }
 
@@ -313,7 +314,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                CoglPixelFormat internal_format,
                                int rowstride,
                                const uint8_t *data,
-                               GError **error)
+                               CoglError **error)
 {
   CoglBitmap *bmp;
   CoglTexture2D *tex_2d;
@@ -347,7 +348,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
                                   int width,
                                   int height,
                                   CoglPixelFormat format,
-                                  GError **error)
+                                  CoglError **error)
 {
   /* NOTE: width, height and internal format are not queriable
    * in GLES, hence such a function prototype.
@@ -469,7 +470,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
                                      int height,
                                      CoglPixelFormat format,
                                      EGLImageKHR image,
-                                     GError **error)
+                                     CoglError **error)
 {
   CoglTexture2D *tex_2d;
   GLenum gl_error;
@@ -495,10 +496,11 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
   ctx->glEGLImageTargetTexture2D (GL_TEXTURE_2D, image);
   if (ctx->glGetError () != GL_NO_ERROR)
     {
-      g_set_error (error,
-                   COGL_TEXTURE_ERROR,
-                   COGL_TEXTURE_ERROR_BAD_PARAMETER,
-                   "Could not create a CoglTexture2D from a given EGLImage");
+      _cogl_set_error (error,
+                       COGL_TEXTURE_ERROR,
+                       COGL_TEXTURE_ERROR_BAD_PARAMETER,
+                       "Could not create a CoglTexture2D from a given "
+                       "EGLImage");
       return NULL;
     }
 
@@ -510,7 +512,7 @@ _cogl_egl_texture_2d_new_from_image (CoglContext *ctx,
 CoglTexture2D *
 cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
                                          struct wl_buffer *buffer,
-                                         GError **error)
+                                         CoglError **error)
 {
   if (wl_buffer_is_shm (buffer))
     {
diff --git a/cogl/cogl-texture-2d.h b/cogl/cogl-texture-2d.h
index bf35e38..2f2d580 100644
--- a/cogl/cogl-texture-2d.h
+++ b/cogl/cogl-texture-2d.h
@@ -77,7 +77,7 @@ cogl_is_texture_2d (void *object);
  * @width: Width of the texture to allocate
  * @height: Height of the texture to allocate
  * @internal_format: The format of the texture
- * @error: A #GError for exceptions
+ * @error: A #CoglError for exceptions
  *
  * Allocates a low-level #CoglTexture2D texture that your GPU can
  * texture from directly. This is unlike sliced textures for example
@@ -102,7 +102,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
                                int width,
                                int height,
                                CoglPixelFormat internal_format,
-                               GError **error);
+                               CoglError **error);
 
 #define cogl_texture_2d_new_from_data cogl_texture_2d_new_from_data_EXP
 /**
@@ -123,7 +123,7 @@ cogl_texture_2d_new_with_size (CoglContext *ctx,
  *    scanlines in @data. A value of 0 will make Cogl automatically
  *    calculate @rowstride from @width and @format.
  * @data: pointer the memory region where the source buffer resides
- * @error: A #GError for exceptions
+ * @error: A #CoglError for exceptions
  *
  * Creates a new #CoglTexture2D texture based on data residing in memory.
  * These are unlike sliced textures for example which may be comprised
@@ -150,7 +150,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
                                CoglPixelFormat internal_format,
                                int rowstride,
                                const uint8_t *data,
-                               GError **error);
+                               CoglError **error);
 
 /**
  * cogl_texture_2d_new_from_bitmap:
@@ -163,7 +163,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
  *    is if you have non-premultiplied source data and are going to adjust
  *    the blend mode (see cogl_pipeline_set_blend()) or use the data for
  *    something other than straight blending.
- * @error: A #GError for exceptions
+ * @error: A #CoglError for exceptions
  *
  * Creates a new #CoglTexture2D texture based on data residing in a
  * bitmap. These are unlike sliced textures for example which may be
@@ -187,7 +187,7 @@ cogl_texture_2d_new_from_data (CoglContext *ctx,
 CoglTexture2D *
 cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap,
                                  CoglPixelFormat internal_format,
-                                 GError **error);
+                                 CoglError **error);
 
 
 #define cogl_texture_2d_new_from_foreign cogl_texture_2d_new_from_foreign_EXP
@@ -198,7 +198,7 @@ cogl_texture_2d_new_from_bitmap (CoglBitmap *bitmap,
  * @width: Width of the foreign GL texture
  * @height: Height of the foreign GL texture
  * @internal_format: The format of the texture
- * @error: A #GError for exceptions
+ * @error: A #CoglError for exceptions
  *
  * Wraps an existing GL_TEXTURE_2D texture object as a #CoglTexture2D.
  * This can be used for integrating Cogl with software using OpenGL
@@ -221,7 +221,7 @@ cogl_texture_2d_new_from_foreign (CoglContext *ctx,
                                   int width,
                                   int height,
                                   CoglPixelFormat format,
-                                  GError **error);
+                                  CoglError **error);
 
 G_END_DECLS
 
diff --git a/cogl/cogl-texture-3d.c b/cogl/cogl-texture-3d.c
index f6a3fd7..3a3f19e 100644
--- a/cogl/cogl-texture-3d.c
+++ b/cogl/cogl-texture-3d.c
@@ -37,6 +37,7 @@
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-private.h"
 #include "cogl-pipeline-opengl-private.h"
+#include "cogl-error-private.h"
 
 #include <string.h>
 #include <math.h>
@@ -146,7 +147,7 @@ _cogl_texture_3d_can_create (CoglContext *ctx,
                              int height,
                              int depth,
                              CoglPixelFormat internal_format,
-                             GError **error)
+                             CoglError **error)
 {
   GLenum gl_intformat;
   GLenum gl_type;
@@ -154,10 +155,10 @@ _cogl_texture_3d_can_create (CoglContext *ctx,
   /* This should only happen on GLES */
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_3D))
     {
-      g_set_error (error,
-                   COGL_ERROR,
-                   COGL_ERROR_UNSUPPORTED,
-                   "3D textures are not supported by the GPU");
+      _cogl_set_error (error,
+                       COGL_SYSTEM_ERROR,
+                       COGL_SYSTEM_ERROR_UNSUPPORTED,
+                       "3D textures are not supported by the GPU");
       return FALSE;
     }
 
@@ -168,11 +169,11 @@ _cogl_texture_3d_can_create (CoglContext *ctx,
        !_cogl_util_is_pot (height) ||
        !_cogl_util_is_pot (depth)))
     {
-      g_set_error (error,
-                   COGL_ERROR,
-                   COGL_ERROR_UNSUPPORTED,
-                   "A non-power-of-two size was requested but this is not "
-                   "supported by the GPU");
+      _cogl_set_error (error,
+                       COGL_SYSTEM_ERROR,
+                       COGL_SYSTEM_ERROR_UNSUPPORTED,
+                       "A non-power-of-two size was requested but this is not "
+                       "supported by the GPU");
       return FALSE;
     }
 
@@ -191,10 +192,10 @@ _cogl_texture_3d_can_create (CoglContext *ctx,
                                                height,
                                                depth))
     {
-      g_set_error (error,
-                   COGL_ERROR,
-                   COGL_ERROR_UNSUPPORTED,
-                   "The requested dimensions are not supported by the GPU");
+      _cogl_set_error (error,
+                       COGL_SYSTEM_ERROR,
+                       COGL_SYSTEM_ERROR_UNSUPPORTED,
+                       "The requested dimensions are not supported by the GPU");
       return FALSE;
     }
 
@@ -207,7 +208,7 @@ cogl_texture_3d_new_with_size (CoglContext *ctx,
                                int height,
                                int depth,
                                CoglPixelFormat internal_format,
-                               GError **error)
+                               CoglError **error)
 {
   CoglTexture3D         *tex_3d;
   GLenum                 gl_intformat;
@@ -249,7 +250,7 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
                                  unsigned int height,
                                  unsigned int depth,
                                  CoglPixelFormat internal_format,
-                                 GError **error)
+                                 CoglError **error)
 {
   CoglTexture3D *tex_3d;
   CoglBitmap *dst_bmp;
@@ -284,8 +285,8 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bmp,
 
   if (dst_bmp == NULL)
     {
-      g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_FAILED,
-                   "Bitmap conversion failed");
+      _cogl_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_FAILED,
+                       "Bitmap conversion failed");
       return NULL;
     }
 
@@ -338,13 +339,13 @@ cogl_texture_3d_new_from_data (CoglContext *context,
                                int rowstride,
                                int image_stride,
                                const uint8_t *data,
-                               GError **error)
+                               CoglError **error)
 {
   CoglBitmap *bitmap;
   CoglTexture3D *ret;
 
   /* These are considered a programmer errors so we won't set a
-     GError. It would be nice if this was a _COGL_RETURN_IF_FAIL but the
+     CoglError. It would be nice if this was a _COGL_RETURN_IF_FAIL but the
      rest of Cogl isn't using that */
   if (format == COGL_PIXEL_FORMAT_ANY)
     return NULL;
diff --git a/cogl/cogl-texture-3d.h b/cogl/cogl-texture-3d.h
index 019be51..1956b4d 100644
--- a/cogl/cogl-texture-3d.h
+++ b/cogl/cogl-texture-3d.h
@@ -57,12 +57,12 @@ typedef struct _CoglTexture3D CoglTexture3D;
  * @depth: depth of the texture in pixels.
  * @internal_format: the #CoglPixelFormat to use for the GPU
  *    storage of the texture.
- * @error: A GError return location.
+ * @error: A CoglError return location.
  *
  * Creates a new Cogl 3D texture with the specified dimensions and
  * pixel format.
  *
- * Note that this function will throw a #GError if
+ * Note that this function will throw a #CoglError if
  * %COGL_FEATURE_TEXTURE_3D is not advertised. It can also fail if the
  * requested dimensions are not supported by the GPU.
  *
@@ -78,7 +78,7 @@ cogl_texture_3d_new_with_size (CoglContext *context,
                                int height,
                                int depth,
                                CoglPixelFormat  internal_format,
-                               GError **error);
+                               CoglError **error);
 
 /**
  * cogl_texture_3d_new_from_data:
@@ -103,13 +103,13 @@ cogl_texture_3d_new_with_size (CoglContext *context,
  *    rows. Alternatively 0 can be passed to infer the @image_stride
  *    from the @height.
  * @data: pointer the memory region where the source buffer resides
- * @error: A GError return location.
+ * @error: A CoglError return location.
  *
  * Creates a new 3D texture and initializes it with @data. The data is
  * assumed to be packed array of @depth images. There can be padding
  * between the images using @image_stride.
  *
- * Note that this function will throw a #GError if
+ * Note that this function will throw a #CoglError if
  * %COGL_FEATURE_TEXTURE_3D is not advertised. It can also fail if the
  * requested dimensions are not supported by the GPU.
  *
@@ -129,7 +129,7 @@ cogl_texture_3d_new_from_data (CoglContext *context,
                                int rowstride,
                                int image_stride,
                                const uint8_t *data,
-                               GError **error);
+                               CoglError **error);
 
 /**
  * cogl_texture_3d_new_from_bitmap:
@@ -144,7 +144,7 @@ cogl_texture_3d_new_from_data (CoglContext *context,
  *    is if you have non-premultiplied source data and are going to adjust
  *    the blend mode (see cogl_pipeline_set_blend()) or use the data for
  *    something other than straight blending.
- * @error: A GError return location.
+ * @error: A CoglError return location.
  *
  * Creates a new 3D texture and initializes it with the images in
  * @bitmap. The images are assumed to be packed together after one
@@ -163,7 +163,7 @@ cogl_texture_3d_new_from_bitmap (CoglBitmap *bitmap,
                                  unsigned int height,
                                  unsigned int depth,
                                  CoglPixelFormat internal_format,
-                                 GError **error);
+                                 CoglError **error);
 
 /**
  * cogl_is_texture_3d:
diff --git a/cogl/cogl-texture-rectangle.c b/cogl/cogl-texture-rectangle.c
index 688bc18..445b734 100644
--- a/cogl/cogl-texture-rectangle.c
+++ b/cogl/cogl-texture-rectangle.c
@@ -37,6 +37,7 @@
 #include "cogl-object-private.h"
 #include "cogl-journal-private.h"
 #include "cogl-pipeline-opengl-private.h"
+#include "cogl-error-private.h"
 
 #include <string.h>
 #include <math.h>
@@ -112,7 +113,7 @@ static CoglBool
 _cogl_texture_rectangle_can_create (unsigned int width,
                                     unsigned int height,
                                     CoglPixelFormat internal_format,
-                                    GError **error)
+                                    CoglError **error)
 {
   GLenum gl_intformat;
   GLenum gl_format;
@@ -122,10 +123,10 @@ _cogl_texture_rectangle_can_create (unsigned int width,
 
   if (!cogl_has_feature (ctx, COGL_FEATURE_ID_TEXTURE_RECTANGLE))
     {
-      g_set_error (error,
-                   COGL_TEXTURE_ERROR,
-                   COGL_TEXTURE_ERROR_TYPE,
-                   "The CoglTextureRectangle feature isn't available");
+      _cogl_set_error (error,
+                       COGL_TEXTURE_ERROR,
+                       COGL_TEXTURE_ERROR_TYPE,
+                       "The CoglTextureRectangle feature isn't available");
       return FALSE;
     }
 
@@ -144,10 +145,10 @@ _cogl_texture_rectangle_can_create (unsigned int width,
                                             width,
                                             height))
     {
-      g_set_error (error,
-                   COGL_TEXTURE_ERROR,
-                   COGL_TEXTURE_ERROR_SIZE,
-                   "The requested texture size + format is unsupported");
+      _cogl_set_error (error,
+                       COGL_TEXTURE_ERROR,
+                       COGL_TEXTURE_ERROR_SIZE,
+                       "The requested texture size + format is unsupported");
       return FALSE;
     }
 
@@ -193,7 +194,7 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
                                       int width,
                                       int height,
                                       CoglPixelFormat internal_format,
-                                      GError **error)
+                                      CoglError **error)
 {
   CoglTextureRectangle *tex_rect;
   GLenum                gl_intformat;
@@ -233,7 +234,7 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
 CoglTextureRectangle *
 cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bmp,
                                         CoglPixelFormat internal_format,
-                                        GError **error)
+                                        CoglError **error)
 {
   CoglTextureRectangle *tex_rect;
   CoglBitmap           *dst_bmp;
diff --git a/cogl/cogl-texture-rectangle.h b/cogl/cogl-texture-rectangle.h
index a40c184..e9a0717 100644
--- a/cogl/cogl-texture-rectangle.h
+++ b/cogl/cogl-texture-rectangle.h
@@ -85,7 +85,7 @@ cogl_is_texture_rectangle (void *object);
  * @width: The texture width to allocate
  * @height: The texture height to allocate
  * @internal_format: The desired internal texture format
- * @error: An optional GError pointer for reporting exceptions
+ * @error: An optional CoglError pointer for reporting exceptions
  *
  * Allocates a new #CoglTextureRectangle texture with a given @width, @height
  * and @internal_format. This texture is a low-level texture that
@@ -111,14 +111,14 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
                                       int width,
                                       int height,
                                       CoglPixelFormat internal_format,
-                                      GError **error);
+                                      CoglError **error);
 
 /**
  * cogl_texture_rectangle_new_from_bitmap:
  * @bitmap: A #CoglBitmap
  * @internal_format: the #CoglPixelFormat to use for the GPU storage of the
  *    texture
- * @error: A return location for a GError or %NULL
+ * @error: A return location for a CoglError or %NULL
  *
  * Allocates a new #CoglTextureRectangle texture which will be
  * initialized with the pixel data from @bitmap. Internally the data
@@ -143,7 +143,7 @@ cogl_texture_rectangle_new_with_size (CoglContext *ctx,
 CoglTextureRectangle *
 cogl_texture_rectangle_new_from_bitmap (CoglBitmap *bitmap,
                                         CoglPixelFormat internal_format,
-                                        GError **error);
+                                        CoglError **error);
 
 G_END_DECLS
 
diff --git a/cogl/cogl-texture.c b/cogl/cogl-texture.c
index 94a0a0e..1d7e938 100644
--- a/cogl/cogl-texture.c
+++ b/cogl/cogl-texture.c
@@ -59,8 +59,8 @@
 #include <stdlib.h>
 #include <math.h>
 
-GQuark
-cogl_texture_error_quark (void)
+uint32_t
+cogl_texture_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-texture-error-quark");
 }
@@ -415,7 +415,7 @@ CoglTexture *
 cogl_texture_new_from_file (const char        *filename,
                             CoglTextureFlags   flags,
                             CoglPixelFormat    internal_format,
-                            GError           **error)
+                            CoglError           **error)
 {
   CoglBitmap *bmp;
   CoglTexture *texture = NULL;
diff --git a/cogl/cogl-texture.h b/cogl/cogl-texture.h
index 0e16807..a629f01 100644
--- a/cogl/cogl-texture.h
+++ b/cogl/cogl-texture.h
@@ -56,12 +56,12 @@ G_BEGIN_DECLS
 /**
  * COGL_TEXTURE_ERROR:
  *
- * #GError domain for texture errors.
+ * #CoglError domain for texture errors.
  *
  * Since: 2.0
  * Stability: Unstable
  */
-#define COGL_TEXTURE_ERROR (cogl_texture_error_quark ())
+#define COGL_TEXTURE_ERROR (cogl_texture_error_domain ())
 
 
 /**
@@ -98,7 +98,7 @@ typedef enum {
   COGL_TEXTURE_TYPE_RECTANGLE
 } CoglTextureType;
 
-GQuark cogl_texture_error_quark (void);
+uint32_t cogl_texture_error_domain (void);
 
 /**
  * cogl_texture_new_with_size:
@@ -132,7 +132,7 @@ cogl_texture_new_with_size (unsigned int width,
  *    have non-premultiplied source data and are going to adjust the blend
  *    mode (see cogl_material_set_blend()) or use the data for something
  *    other than straight blending.
- * @error: return location for a #GError or %NULL
+ * @error: return location for a #CoglError or %NULL
  *
  * Creates a #CoglTexture from an image file.
  *
@@ -144,7 +144,7 @@ CoglTexture *
 cogl_texture_new_from_file (const char       *filename,
                             CoglTextureFlags   flags,
                             CoglPixelFormat    internal_format,
-                            GError           **error);
+                            CoglError           **error);
 
 /**
  * cogl_texture_new_from_data:
diff --git a/cogl/cogl-types.h b/cogl/cogl-types.h
index 9e61ca4..44a13c2 100644
--- a/cogl/cogl-types.h
+++ b/cogl/cogl-types.h
@@ -458,11 +458,11 @@ typedef enum {
 /**
  * COGL_BLEND_STRING_ERROR:
  *
- * #GError domain for blend string parser errors
+ * #CoglError domain for blend string parser errors
  *
  * Since: 1.0
  */
-#define COGL_BLEND_STRING_ERROR (cogl_blend_string_error_quark ())
+#define COGL_BLEND_STRING_ERROR (cogl_blend_string_error_domain ())
 
 /**
  * CoglBlendStringError:
@@ -483,28 +483,28 @@ typedef enum { /*< prefix=COGL_BLEND_STRING_ERROR >*/
   COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR
 } CoglBlendStringError;
 
-GQuark
-cogl_blend_string_error_quark (void);
+uint32_t
+cogl_blend_string_error_domain (void);
 
-#define COGL_ERROR (_cogl_error_quark ())
+#define COGL_SYSTEM_ERROR (_cogl_system_error_domain ())
 
 /**
- * CoglError:
- * @COGL_ERROR_UNSUPPORTED: You tried to use a feature or
+ * CoglSystemError:
+ * @COGL_SYSTEM_ERROR_UNSUPPORTED: You tried to use a feature or
  *    configuration not currently available.
- * @COGL_ERROR_NO_MEMORY: You tried to allocate a resource
+ * @COGL_SYSTEM_ERROR_NO_MEMORY: You tried to allocate a resource
  *    such as a texture and there wasn't enough memory.
  *
  * Error enumeration for Cogl
  *
- * The @COGL_ERROR_UNSUPPORTED error can be thrown for a variety of
- * reasons. For example:
+ * The @COGL_SYSTEM_ERROR_UNSUPPORTED error can be thrown for a
+ * variety of reasons. For example:
  *
  * <itemizedlist>
  *  <listitem><para>You've tried to use a feature that is not
- *   advertised by cogl_get_features(). This could happen if you create
+ *   advertised by cogl_has_feature(). This could happen if you create
  *   a 2d texture with a non-power-of-two size when
- *   %COGL_FEATURE_TEXTURE_NPOT is not advertised.</para></listitem>
+ *   %COGL_FEATURE_ID_TEXTURE_NPOT is not advertised.</para></listitem>
  *  <listitem><para>The GPU can not handle the configuration you have
  *   requested. An example might be if you try to use too many texture
  *   layers in a single #CoglPipeline</para></listitem>
@@ -519,12 +519,12 @@ cogl_blend_string_error_quark (void);
  * Stability: unstable
  */
 typedef enum { /*< prefix=COGL_ERROR >*/
-  COGL_ERROR_UNSUPPORTED,
-  COGL_ERROR_NO_MEMORY
-} CoglError;
+  COGL_SYSTEM_ERROR_UNSUPPORTED,
+  COGL_SYSTEM_ERROR_NO_MEMORY
+} CoglSystemError;
 
-GQuark
-_cogl_error_quark (void);
+uint32_t
+_cogl_system_error_domain (void);
 
 /**
  * CoglAttributeType:
diff --git a/cogl/cogl-wayland-server.h b/cogl/cogl-wayland-server.h
index 315af22..6e66292 100644
--- a/cogl/cogl-wayland-server.h
+++ b/cogl/cogl-wayland-server.h
@@ -54,7 +54,7 @@ cogl_wayland_display_set_compositor_display (CoglDisplay *display,
  * cogl_wayland_texture_2d_new_from_buffer:
  * @ctx: A #CoglContext
  * @buffer: A Wayland buffer
- * @error: A #GError for exceptions
+ * @error: A #CoglError for exceptions
  *
  * Uploads the given Wayland @buffer to a #CoglTexture2D.
  *
@@ -77,7 +77,7 @@ cogl_wayland_display_set_compositor_display (CoglDisplay *display,
 CoglTexture2D *
 cogl_wayland_texture_2d_new_from_buffer (CoglContext *ctx,
                                          struct wl_buffer *buffer,
-                                         GError **error);
+                                         CoglError **error);
 
 G_END_DECLS
 
diff --git a/cogl/cogl-xlib-renderer-private.h b/cogl/cogl-xlib-renderer-private.h
index 0c73b5c..4970f20 100644
--- a/cogl/cogl-xlib-renderer-private.h
+++ b/cogl/cogl-xlib-renderer-private.h
@@ -44,7 +44,7 @@ typedef struct _CoglXlibRenderer
 } CoglXlibRenderer;
 
 CoglBool
-_cogl_xlib_renderer_connect (CoglRenderer *renderer, GError **error);
+_cogl_xlib_renderer_connect (CoglRenderer *renderer, CoglError **error);
 
 void
 _cogl_xlib_renderer_disconnect (CoglRenderer *renderer);
diff --git a/cogl/cogl-xlib-renderer.c b/cogl/cogl-xlib-renderer.c
index 9ae7765..713df7f 100644
--- a/cogl/cogl-xlib-renderer.c
+++ b/cogl/cogl-xlib-renderer.c
@@ -37,6 +37,7 @@
 #include "cogl-xlib-renderer-private.h"
 #include "cogl-x11-renderer-private.h"
 #include "cogl-winsys-private.h"
+#include "cogl-error-private.h"
 
 #include <X11/Xlib.h>
 #include <X11/extensions/Xdamage.h>
@@ -164,7 +165,7 @@ _cogl_xlib_renderer_untrap_errors (CoglRenderer *renderer,
 }
 
 static Display *
-assert_xlib_display (CoglRenderer *renderer, GError **error)
+assert_xlib_display (CoglRenderer *renderer, CoglError **error)
 {
   Display *xdpy = cogl_xlib_renderer_get_foreign_display (renderer);
   CoglXlibRenderer *xlib_renderer = _cogl_xlib_renderer_get_data (renderer);
@@ -179,7 +180,7 @@ assert_xlib_display (CoglRenderer *renderer, GError **error)
   xdpy = XOpenDisplay (_cogl_x11_display_name);
   if (xdpy == NULL)
     {
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_RENDERER_ERROR,
                    COGL_RENDERER_ERROR_XLIB_DISPLAY_OPEN,
                    "Failed to open X Display %s", _cogl_x11_display_name);
@@ -191,7 +192,7 @@ assert_xlib_display (CoglRenderer *renderer, GError **error)
 }
 
 CoglBool
-_cogl_xlib_renderer_connect (CoglRenderer *renderer, GError **error)
+_cogl_xlib_renderer_connect (CoglRenderer *renderer, CoglError **error)
 {
   CoglXlibRenderer *xlib_renderer =
     _cogl_xlib_renderer_get_data (renderer);
diff --git a/cogl/cogl.c b/cogl/cogl.c
index 6dff1c1..9c4ab25 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -157,8 +157,8 @@ cogl_flush (void)
     _cogl_framebuffer_flush_journal (l->data);
 }
 
-GQuark
-_cogl_driver_error_quark (void)
+uint32_t
+_cogl_driver_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-driver-error-quark");
 }
@@ -203,10 +203,10 @@ _cogl_transform_point (const CoglMatrix *matrix_mv,
 #undef VIEWPORT_TRANSFORM_X
 #undef VIEWPORT_TRANSFORM_Y
 
-GQuark
-_cogl_error_quark (void)
+uint32_t
+_cogl_system_error_domain (void)
 {
-  return g_quark_from_static_string ("cogl-error-quark");
+  return g_quark_from_static_string ("cogl-system-error-quark");
 }
 
 void
diff --git a/cogl/cogl.h b/cogl/cogl.h
index 2072c88..597f1d5 100644
--- a/cogl/cogl.h
+++ b/cogl/cogl.h
@@ -34,6 +34,7 @@
  */
 
 #include <cogl/cogl-defines.h>
+#include <cogl/cogl-error.h>
 
 #include <cogl/cogl-object.h>
 #include <cogl/cogl1-context.h>
diff --git a/cogl/cogl.symbols b/cogl/cogl.symbols
index 973f322..bdcac1d 100644
--- a/cogl/cogl.symbols
+++ b/cogl/cogl.symbols
@@ -38,7 +38,7 @@ cogl_attribute_type_get_type
 cogl_begin_gl
 
 cogl_bitmap_error_get_type
-cogl_bitmap_error_quark
+cogl_bitmap_error_domain
 cogl_bitmap_get_buffer
 cogl_bitmap_get_format
 cogl_bitmap_get_height
@@ -50,7 +50,7 @@ cogl_bitmap_new_from_file
 cogl_bitmap_new_from_buffer
 cogl_bitmap_new_with_size
 cogl_blend_string_error_get_type
-cogl_blend_string_error_quark
+cogl_blend_string_error_domain
 
 cogl_buffer_bit_get_type
 cogl_buffer_get_size
@@ -194,7 +194,7 @@ cogl_framebuffer_draw_rectangle
 cogl_framebuffer_draw_rectangles
 cogl_framebuffer_draw_textured_rectangle
 cogl_framebuffer_draw_textured_rectangles
-cogl_framebuffer_error_quark
+cogl_framebuffer_error_domain
 cogl_framebuffer_fill_path
 cogl_framebuffer_finish
 cogl_framebuffer_frustum
@@ -512,7 +512,7 @@ cogl_renderer_connect
 cogl_renderer_get_driver
 cogl_renderer_get_n_fragment_texture_units
 cogl_renderer_error_get_type
-cogl_renderer_error_quark
+cogl_renderer_error_domain
 cogl_renderer_get_winsys_id
 cogl_renderer_new
 cogl_renderer_remove_constraint
@@ -559,7 +559,7 @@ cogl_swap_chain_new_EXP
 cogl_swap_chain_set_has_alpha_EXP
 cogl_swap_chain_set_length_EXP
 
-cogl_texture_error_quark
+cogl_texture_error_domain
 cogl_texture_flags_get_type
 cogl_texture_get_data
 cogl_texture_get_format
@@ -576,7 +576,7 @@ cogl_texture_new_from_foreign
 cogl_texture_new_from_sub_texture
 cogl_texture_new_with_size
 #ifdef COGL_HAS_X11
-cogl_texture_pixmap_x11_error_quark
+cogl_texture_pixmap_x11_error_domain
 cogl_texture_pixmap_x11_is_using_tfp_extension
 cogl_texture_pixmap_x11_new
 cogl_texture_pixmap_x11_set_damage_object
@@ -675,7 +675,7 @@ _cogl_atlas_texture_new_from_bitmap
 _cogl_atlas_texture_new_with_size
 _cogl_atlas_texture_remove_reorganize_callback
 _cogl_context_get_default
-_cogl_error_quark
+_cogl_system_error_domain
 _cogl_texture_associate_framebuffer
 _cogl_texture_can_hardware_repeat
 _cogl_texture_determine_internal_format
diff --git a/cogl/driver/gl/cogl-gl.c b/cogl/driver/gl/cogl-gl.c
index fed8737..fbe9e6d 100644
--- a/cogl/driver/gl/cogl-gl.c
+++ b/cogl/driver/gl/cogl-gl.c
@@ -32,6 +32,7 @@
 #include "cogl-context-private.h"
 #include "cogl-feature-private.h"
 #include "cogl-renderer-private.h"
+#include "cogl-error-private.h"
 
 static CoglBool
 _cogl_driver_pixel_format_from_gl_internal (CoglContext *context,
@@ -258,14 +259,14 @@ _cogl_get_gl_version (CoglContext *ctx,
 
 static CoglBool
 check_gl_version (CoglContext *ctx,
-                  GError **error)
+                  CoglError **error)
 {
   int major, minor;
   const char *gl_extensions;
 
   if (!_cogl_get_gl_version (ctx, &major, &minor))
     {
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_DRIVER_ERROR,
                    COGL_DRIVER_ERROR_UNKNOWN_VERSION,
                    "The OpenGL version could not be determined");
@@ -282,7 +283,7 @@ check_gl_version (CoglContext *ctx,
      extension */
   if (!_cogl_check_extension ("GL_ARB_multitexture", gl_extensions))
     {
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_DRIVER_ERROR,
                    COGL_DRIVER_ERROR_INVALID_VERSION,
                    "The OpenGL driver is missing "
@@ -293,7 +294,7 @@ check_gl_version (CoglContext *ctx,
   /* OpenGL 1.2 is required */
   if (!COGL_CHECK_GL_VERSION (major, minor, 1, 2))
     {
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_DRIVER_ERROR,
                    COGL_DRIVER_ERROR_INVALID_VERSION,
                    "The OpenGL version of your driver (%i.%i) "
@@ -307,7 +308,7 @@ check_gl_version (CoglContext *ctx,
 
 static CoglBool
 _cogl_driver_update_features (CoglContext *ctx,
-                              GError **error)
+                              CoglError **error)
 {
   CoglPrivateFeatureFlags private_flags = 0;
   CoglFeatureFlags flags = 0;
diff --git a/cogl/driver/gles/cogl-gles.c b/cogl/driver/gles/cogl-gles.c
index 417fee5..da47e0b 100644
--- a/cogl/driver/gles/cogl-gles.c
+++ b/cogl/driver/gles/cogl-gles.c
@@ -159,7 +159,7 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
 
 static CoglBool
 _cogl_driver_update_features (CoglContext *context,
-                              GError **error)
+                              CoglError **error)
 {
   CoglPrivateFeatureFlags private_flags = 0;
   CoglFeatureFlags flags = 0;
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.c b/cogl/winsys/cogl-texture-pixmap-x11.c
index ec855b3..18a2370 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.c
+++ b/cogl/winsys/cogl-texture-pixmap-x11.c
@@ -47,6 +47,7 @@
 #include "cogl-winsys-private.h"
 #include "cogl-pipeline-opengl-private.h"
 #include "cogl-xlib.h"
+#include "cogl-error-private.h"
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -64,8 +65,8 @@ COGL_TEXTURE_DEFINE (TexturePixmapX11, texture_pixmap_x11);
 
 static const CoglTextureVtable cogl_texture_pixmap_x11_vtable;
 
-GQuark
-cogl_texture_pixmap_x11_error_quark (void)
+uint32_t
+cogl_texture_pixmap_x11_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-texture-pixmap-error-quark");
 }
@@ -273,7 +274,7 @@ CoglTexturePixmapX11 *
 cogl_texture_pixmap_x11_new (CoglContext *ctxt,
                              uint32_t pixmap,
                              CoglBool automatic_updates,
-                             GError **error)
+                             CoglError **error)
 {
   CoglTexturePixmapX11 *tex_pixmap = g_new (CoglTexturePixmapX11, 1);
   Display *display = cogl_xlib_get_display ();
@@ -300,7 +301,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
                      &pixmap_border_width, &tex_pixmap->depth))
     {
       g_free (tex_pixmap);
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_TEXTURE_PIXMAP_X11_ERROR,
                    COGL_TEXTURE_PIXMAP_X11_ERROR_X11,
                    "Unable to query pixmap size");
@@ -312,7 +313,7 @@ cogl_texture_pixmap_x11_new (CoglContext *ctxt,
   if (!XGetWindowAttributes (display, pixmap_root_window, &window_attributes))
     {
       g_free (tex_pixmap);
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_TEXTURE_PIXMAP_X11_ERROR,
                    COGL_TEXTURE_PIXMAP_X11_ERROR_X11,
                    "Unable to query root window attributes");
diff --git a/cogl/winsys/cogl-texture-pixmap-x11.h b/cogl/winsys/cogl-texture-pixmap-x11.h
index 20a2afe..77ff942 100644
--- a/cogl/winsys/cogl-texture-pixmap-x11.h
+++ b/cogl/winsys/cogl-texture-pixmap-x11.h
@@ -57,11 +57,11 @@ typedef enum
 /**
  * COGL_TEXTURE_PIXMAP_X11_ERROR:
  *
- * #GError domain for texture-pixmap-x11 errors.
+ * #CoglError domain for texture-pixmap-x11 errors.
  *
  * Since: 1.10
  */
-#define COGL_TEXTURE_PIXMAP_X11_ERROR (cogl_texture_pixmap_x11_error_quark ())
+#define COGL_TEXTURE_PIXMAP_X11_ERROR (cogl_texture_pixmap_x11_error_domain ())
 
 /**
  * CoglTexturePixmapX11Error:
@@ -76,7 +76,7 @@ typedef enum {
   COGL_TEXTURE_PIXMAP_X11_ERROR_X11,
 } CoglTexturePixmapX11Error;
 
-GQuark cogl_texture_pixmap_x11_error_quark (void);
+uint32_t cogl_texture_pixmap_x11_error_domain (void);
 
 /**
  * cogl_texture_pixmap_x11_new:
@@ -84,7 +84,7 @@ GQuark cogl_texture_pixmap_x11_error_quark (void);
  * @pixmap: A X11 pixmap ID
  * @automatic_updates: Whether to automatically copy the contents of
  * the pixmap to the texture.
- * @error: A #GError for exceptions
+ * @error: A #CoglError for exceptions
  *
  * Creates a texture that contains the contents of @pixmap. If
  * @automatic_updates is %TRUE then Cogl will attempt to listen for
@@ -100,7 +100,7 @@ CoglTexturePixmapX11 *
 cogl_texture_pixmap_x11_new (CoglContext *context,
                              uint32_t pixmap,
                              CoglBool automatic_updates,
-                             GError **error);
+                             CoglError **error);
 
 /**
  * cogl_texture_pixmap_x11_update_area:
diff --git a/cogl/winsys/cogl-winsys-egl-android.c b/cogl/winsys/cogl-winsys-egl-android.c
index 4f52cde..a061f1f 100644
--- a/cogl/winsys/cogl-winsys-egl-android.c
+++ b/cogl/winsys/cogl-winsys-egl-android.c
@@ -69,7 +69,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglRendererEGL *egl_renderer;
 
@@ -92,7 +92,7 @@ error:
 
 static CoglBool
 _cogl_winsys_egl_context_created (CoglDisplay *display,
-                                  GError **error)
+                                  CoglError **error)
 {
   CoglRenderer *renderer = display->renderer;
   CoglRendererEGL *egl_renderer = renderer->winsys;
@@ -154,7 +154,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
   return TRUE;
 
  fail:
-  g_set_error (error, COGL_WINSYS_ERROR,
+  _cogl_set_error (error, COGL_WINSYS_ERROR,
                COGL_WINSYS_ERROR_CREATE_CONTEXT,
                "%s", error_message);
   return FALSE;
@@ -162,7 +162,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
 
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
-                                GError **error)
+                                CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayAndroid *android_display;
@@ -184,7 +184,7 @@ _cogl_winsys_egl_display_destroy (CoglDisplay *display)
 static CoglBool
 _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                                 EGLConfig egl_config,
-                                GError **error)
+                                CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -195,7 +195,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
 
   if (android_display->have_onscreen)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "EGL platform only supports a single onscreen window");
       return FALSE;
diff --git a/cogl/winsys/cogl-winsys-egl-gdl.c b/cogl/winsys/cogl-winsys-egl-gdl.c
index 8d57904..f8b4a13 100644
--- a/cogl/winsys/cogl-winsys-egl-gdl.c
+++ b/cogl/winsys/cogl-winsys-egl-gdl.c
@@ -67,7 +67,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglRendererEGL *egl_renderer;
   CoglRendererGDL *gdl_renderer;
@@ -91,7 +91,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   rc = gdl_init (NULL);
   if (rc != GDL_SUCCESS)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "GDL initialize failed. %s",
                    gdl_get_error_string (rc));
@@ -101,7 +101,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &gdl_display_info);
   if (rc != GDL_SUCCESS)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "GDL failed to get display information: %s",
                    gdl_get_error_string (rc));
@@ -120,7 +120,7 @@ error:
 
 static CoglBool
 _cogl_winsys_egl_context_created (CoglDisplay *display,
-                                  GError **error)
+                                  CoglError **error)
 {
   CoglRenderer *renderer = display->renderer;
   CoglRendererEGL *egl_renderer = renderer->winsys;
@@ -162,14 +162,14 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
   return TRUE;
 
  fail:
-  g_set_error (error, COGL_WINSYS_ERROR,
+  _cogl_set_error (error, COGL_WINSYS_ERROR,
                COGL_WINSYS_ERROR_CREATE_CONTEXT,
                "%s", error_message);
   return FALSE;
 }
 
 static CoglBool
-gdl_plane_init (CoglDisplay *display, GError **error)
+gdl_plane_init (CoglDisplay *display, CoglError **error)
 {
   CoglBool ret = TRUE;
   gdl_color_space_t colorSpace = GDL_COLOR_SPACE_RGB;
@@ -180,7 +180,7 @@ gdl_plane_init (CoglDisplay *display, GError **error)
 
   if (!display->gdl_plane)
     {
-      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+      _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "No GDL plane specified with "
                    "cogl_gdl_display_set_plane");
       return FALSE;
@@ -189,7 +189,7 @@ gdl_plane_init (CoglDisplay *display, GError **error)
   rc = gdl_init (NULL);
   if (rc != GDL_SUCCESS)
     {
-      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+      _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "GDL initialize failed. %s", gdl_get_error_string (rc));
       return FALSE;
     }
@@ -197,7 +197,7 @@ gdl_plane_init (CoglDisplay *display, GError **error)
   rc = gdl_get_display_info (GDL_DISPLAY_ID_0, &display_info);
   if (rc != GDL_SUCCESS)
     {
-      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+      _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "GDL failed to get display infomation: %s",
                    gdl_get_error_string (rc));
       gdl_close ();
@@ -243,7 +243,7 @@ gdl_plane_init (CoglDisplay *display, GError **error)
 
   if (rc != GDL_SUCCESS)
     {
-      g_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
+      _cogl_set_error (error, COGL_WINSYS_ERROR, COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "GDL configuration failed: %s.", gdl_get_error_string (rc));
       ret = FALSE;
     }
@@ -255,7 +255,7 @@ gdl_plane_init (CoglDisplay *display, GError **error)
 
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
-                                GError **error)
+                                CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayGDL *gdl_display;
@@ -294,7 +294,7 @@ _cogl_winsys_egl_cleanup_context (CoglDisplay *display)
 static CoglBool
 _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                                 EGLConfig egl_config,
-                                GError **error)
+                                CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -305,7 +305,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
 
   if (gdl_display->have_onscreen)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "EGL platform only supports a single onscreen window");
       return FALSE;
diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
index e1d098e..ff538e2 100644
--- a/cogl/winsys/cogl-winsys-egl-kms.c
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
@@ -52,6 +52,7 @@
 #include "cogl-kms-renderer.h"
 #include "cogl-kms-display.h"
 #include "cogl-version.h"
+#include "cogl-error-private.h"
 
 static const CoglWinsysEGLVtable _cogl_winsys_egl_vtable;
 
@@ -115,7 +116,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglRendererEGL *egl_renderer;
   CoglRendererKMS *kms_renderer;
@@ -131,7 +132,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   if (kms_renderer->fd < 0)
     {
       /* Probably permissions error */
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Couldn't open %s", device_name);
       return FALSE;
@@ -140,7 +141,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   kms_renderer->gbm = gbm_create_device (kms_renderer->fd);
   if (kms_renderer->gbm == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Couldn't create gbm device");
       goto close_fd;
@@ -149,7 +150,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
   egl_renderer->edpy = eglGetDisplay ((EGLNativeDisplayType)kms_renderer->gbm);
   if (egl_renderer->edpy == EGL_NO_DISPLAY)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Couldn't get eglDisplay");
       goto destroy_gbm_device;
@@ -264,7 +265,7 @@ find_output (int _index,
              drmModeRes *resources,
              int *excluded_connectors,
              int n_excluded_connectors,
-             GError **error)
+             CoglError **error)
 {
   char *connector_env_name = g_strdup_printf ("COGL_KMS_CONNECTOR%d", _index);
   char *mode_env_name;
@@ -288,7 +289,7 @@ find_output (int _index,
                                 excluded_connectors, n_excluded_connectors);
   if (connector == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "No currently active connector found");
       return NULL;
@@ -340,7 +341,7 @@ find_output (int _index,
       if (!found)
         {
           g_free (mode_env_name);
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_INIT,
                        "COGL_KMS_CONNECTOR%d_MODE of %s could not be found",
                        _index, name);
@@ -384,7 +385,7 @@ setup_crtc_modes (CoglDisplay *display, int fb_id)
 
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
-                                GError **error)
+                                CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayKMS *kms_display;
@@ -400,7 +401,7 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display,
   resources = drmModeGetResources (kms_renderer->fd);
   if (!resources)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "drmModeGetResources failed");
       return FALSE;
@@ -440,7 +441,7 @@ _cogl_winsys_egl_display_setup (CoglDisplay *display,
                               &output0->mode,
                               &output1->mode))
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_INIT,
                        "Failed to find matching modes for mirroring");
           return FALSE;
@@ -508,7 +509,7 @@ _cogl_winsys_egl_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_egl_context_created (CoglDisplay *display,
-                                  GError **error)
+                                  CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayKMS *kms_display = egl_display->platform;
@@ -522,7 +523,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
                                                        GBM_BO_USE_RENDERING);
   if (!kms_display->dummy_gbm_surface)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Failed to create dummy GBM surface");
       return FALSE;
@@ -535,7 +536,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
                             NULL);
   if (egl_display->dummy_surface == EGL_NO_SURFACE)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Failed to create dummy EGL surface");
       return FALSE;
@@ -546,7 +547,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
                                       egl_display->dummy_surface,
                                       egl_display->egl_context))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Failed to make context current");
       return FALSE;
@@ -749,7 +750,7 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
 
 static CoglBool
 _cogl_winsys_egl_context_init (CoglContext *context,
-                               GError **error)
+                               CoglError **error)
 {
   COGL_FLAGS_SET (context->features,
                   COGL_FEATURE_ID_SWAP_BUFFERS_EVENT, TRUE);
@@ -762,7 +763,7 @@ _cogl_winsys_egl_context_init (CoglContext *context,
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -793,7 +794,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
 
   if (!kms_onscreen->surface)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "Failed to allocate surface");
       return FALSE;
@@ -806,7 +807,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
                             NULL);
   if (egl_onscreen->egl_surface == EGL_NO_SURFACE)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "Failed to allocate surface");
       return FALSE;
diff --git a/cogl/winsys/cogl-winsys-egl-null.c b/cogl/winsys/cogl-winsys-egl-null.c
index 65da170..ee817e0 100644
--- a/cogl/winsys/cogl-winsys-egl-null.c
+++ b/cogl/winsys/cogl-winsys-egl-null.c
@@ -56,7 +56,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglRendererEGL *egl_renderer;
 
@@ -79,7 +79,7 @@ error:
 
 static CoglBool
 _cogl_winsys_egl_context_created (CoglDisplay *display,
-                                  GError **error)
+                                  CoglError **error)
 {
   CoglRenderer *renderer = display->renderer;
   CoglRendererEGL *egl_renderer = renderer->winsys;
@@ -120,7 +120,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
   return TRUE;
 
  fail:
-  g_set_error (error, COGL_WINSYS_ERROR,
+  _cogl_set_error (error, COGL_WINSYS_ERROR,
                COGL_WINSYS_ERROR_CREATE_CONTEXT,
                "%s", error_message);
   return FALSE;
@@ -128,7 +128,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
 
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
-                                GError **error)
+                                CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayNull *null_display;
@@ -164,7 +164,7 @@ _cogl_winsys_egl_cleanup_context (CoglDisplay *display)
 static CoglBool
 _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                                 EGLConfig egl_config,
-                                GError **error)
+                                CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -175,7 +175,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
 
   if (null_display->have_onscreen)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "EGL platform only supports a single onscreen window");
       return FALSE;
diff --git a/cogl/winsys/cogl-winsys-egl-private.h b/cogl/winsys/cogl-winsys-egl-private.h
index eeb7028..3f092ae 100644
--- a/cogl/winsys/cogl-winsys-egl-private.h
+++ b/cogl/winsys/cogl-winsys-egl-private.h
@@ -34,19 +34,19 @@ typedef struct _CoglWinsysEGLVtable
 {
   CoglBool
   (* display_setup) (CoglDisplay *display,
-                     GError **error);
+                     CoglError **error);
   void
   (* display_destroy) (CoglDisplay *display);
 
   CoglBool
   (* context_created) (CoglDisplay *display,
-                       GError **error);
+                       CoglError **error);
 
   void
   (* cleanup_context) (CoglDisplay *display);
 
   CoglBool
-  (* context_init) (CoglContext *context, GError **error);
+  (* context_init) (CoglContext *context, CoglError **error);
 
   void
   (* context_deinit) (CoglContext *context);
@@ -54,7 +54,7 @@ typedef struct _CoglWinsysEGLVtable
   CoglBool
   (* onscreen_init) (CoglOnscreen *onscreen,
                      EGLConfig config,
-                     GError **error);
+                     CoglError **error);
   void
   (* onscreen_deinit) (CoglOnscreen *onscreen);
 
@@ -159,6 +159,6 @@ _cogl_egl_destroy_image (CoglContext *ctx,
 
 CoglBool
 _cogl_winsys_egl_renderer_connect_common (CoglRenderer *renderer,
-                                          GError **error);
+                                          CoglError **error);
 
 #endif /* __COGL_WINSYS_EGL_PRIVATE_H */
diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
index c1dec24..694ecc1 100644
--- a/cogl/winsys/cogl-winsys-egl-wayland.c
+++ b/cogl/winsys/cogl-winsys-egl-wayland.c
@@ -38,6 +38,7 @@
 #include "cogl-renderer-private.h"
 #include "cogl-onscreen-private.h"
 #include "cogl-wayland-renderer.h"
+#include "cogl-error-private.h"
 
 static const CoglWinsysEGLVtable _cogl_winsys_egl_vtable;
 
@@ -103,7 +104,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglRendererEGL *egl_renderer;
   CoglRendererWayland *wayland_renderer;
@@ -139,7 +140,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
       wayland_renderer->wayland_display = wl_display_connect (NULL);
       if (!wayland_renderer->wayland_display)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_INIT,
                        "Failed to connect wayland display");
           goto error;
@@ -175,7 +176,7 @@ error:
 
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
-                                GError **error)
+                                CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayWayland *wayland_display;
@@ -196,7 +197,7 @@ _cogl_winsys_egl_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_egl_context_created (CoglDisplay *display,
-                                  GError **error)
+                                  CoglError **error)
 {
   CoglRenderer *renderer = display->renderer;
   CoglRendererEGL *egl_renderer = renderer->winsys;
@@ -247,7 +248,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
   return TRUE;
 
  fail:
-  g_set_error (error, COGL_WINSYS_ERROR,
+  _cogl_set_error (error, COGL_WINSYS_ERROR,
                COGL_WINSYS_ERROR_CREATE_CONTEXT,
                "%s", error_message);
   return FALSE;
@@ -282,7 +283,7 @@ _cogl_winsys_egl_cleanup_context (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_egl_context_init (CoglContext *context,
-                               GError **error)
+                               CoglError **error)
 {
   context->feature_flags |= COGL_FEATURE_ONSCREEN_MULTIPLE;
   COGL_FLAGS_SET (context->features,
@@ -297,7 +298,7 @@ _cogl_winsys_egl_context_init (CoglContext *context,
 static CoglBool
 _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                                 EGLConfig egl_config,
-                                GError **error)
+                                CoglError **error)
 {
   CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
   CoglOnscreenWayland *wayland_onscreen;
@@ -314,7 +315,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
     wl_compositor_create_surface (wayland_renderer->wayland_compositor);
   if (!wayland_onscreen->wayland_surface)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "Error while creating wayland surface for CoglOnscreen");
       return FALSE;
@@ -330,7 +331,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                           cogl_framebuffer_get_height (framebuffer));
   if (!wayland_onscreen->wayland_egl_native_window)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "Error while creating wayland egl native window "
                    "for CoglOnscreen");
diff --git a/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/winsys/cogl-winsys-egl-x11.c
index 1b02ac0..fca7609 100644
--- a/cogl/winsys/cogl-winsys-egl-x11.c
+++ b/cogl/winsys/cogl-winsys-egl-x11.c
@@ -42,6 +42,7 @@
 
 #include "cogl-texture-pixmap-x11-private.h"
 #include "cogl-texture-2d-private.h"
+#include "cogl-error-private.h"
 
 #define COGL_ONSCREEN_X11_EVENT_MASK StructureNotifyMask
 
@@ -194,7 +195,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglRendererEGL *egl_renderer;
   CoglXlibRenderer *xlib_renderer;
@@ -223,7 +224,7 @@ error:
 
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
-                                GError **error)
+                                CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
   CoglDisplayXlib *xlib_display;
@@ -244,7 +245,7 @@ _cogl_winsys_egl_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_egl_context_init (CoglContext *context,
-                               GError **error)
+                               CoglError **error)
 {
   cogl_xlib_renderer_add_filter (context->display->renderer,
                                  event_filter_cb,
@@ -271,7 +272,7 @@ _cogl_winsys_egl_context_deinit (CoglContext *context)
 static CoglBool
 _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
                                 EGLConfig egl_config,
-                                GError **error)
+                                CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -312,7 +313,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
           char message[1000];
           XGetErrorText (xlib_renderer->xdpy, xerror,
                          message, sizeof (message));
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "Unable to query geometry of foreign "
                        "xid 0x%08lX: %s",
@@ -347,7 +348,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
       xvisinfo = get_visual_info (display, egl_config);
       if (xvisinfo == NULL)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "Unable to retrieve the X11 visual of context's "
                        "fbconfig");
@@ -389,7 +390,7 @@ _cogl_winsys_egl_onscreen_init (CoglOnscreen *onscreen,
           char message[1000];
           XGetErrorText (xlib_renderer->xdpy, xerror,
                          message, sizeof (message));
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "X error while creating Window for CoglOnscreen: %s",
                        message);
@@ -510,7 +511,7 @@ _cogl_winsys_onscreen_x11_get_window_xid (CoglOnscreen *onscreen)
 
 static CoglBool
 _cogl_winsys_egl_context_created (CoglDisplay *display,
-                                  GError **error)
+                                  CoglError **error)
 {
   CoglRenderer *renderer = display->renderer;
   CoglDisplayEGL *egl_display = display->winsys;
@@ -575,7 +576,7 @@ _cogl_winsys_egl_context_created (CoglDisplay *display,
   return TRUE;
 
 fail:
-  g_set_error (error, COGL_WINSYS_ERROR,
+  _cogl_set_error (error, COGL_WINSYS_ERROR,
                COGL_WINSYS_ERROR_CREATE_CONTEXT,
                "%s", error_message);
   return FALSE;
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 800ebce..dcd17ed 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -39,6 +39,7 @@
 #include "cogl-renderer-private.h"
 #include "cogl-onscreen-template-private.h"
 #include "cogl-gles2-context-private.h"
+#include "cogl-error-private.h"
 
 #include "cogl-private.h"
 
@@ -168,7 +169,7 @@ check_egl_extensions (CoglRenderer *renderer)
 
 CoglBool
 _cogl_winsys_egl_renderer_connect_common (CoglRenderer *renderer,
-                                          GError **error)
+                                          CoglError **error)
 {
   CoglRendererEGL *egl_renderer = renderer->winsys;
 
@@ -176,7 +177,7 @@ _cogl_winsys_egl_renderer_connect_common (CoglRenderer *renderer,
                       &egl_renderer->egl_version_major,
                       &egl_renderer->egl_version_minor))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Couldn't initialize EGL");
       return FALSE;
@@ -189,7 +190,7 @@ _cogl_winsys_egl_renderer_connect_common (CoglRenderer *renderer,
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   /* This function must be overridden by a platform winsys */
   g_assert_not_reached ();
@@ -256,7 +257,7 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
 static CoglBool
 try_create_context (CoglDisplay *display,
                     CoglBool with_stencil_buffer,
-                    GError **error)
+                    CoglError **error)
 {
   CoglRenderer *renderer = display->renderer;
   CoglDisplayEGL *egl_display = display->winsys;
@@ -319,7 +320,7 @@ try_create_context (CoglDisplay *display,
   return TRUE;
 
 fail:
-  g_set_error (error, COGL_WINSYS_ERROR,
+  _cogl_set_error (error, COGL_WINSYS_ERROR,
                COGL_WINSYS_ERROR_CREATE_CONTEXT,
                "%s", error_message);
   return FALSE;
@@ -373,7 +374,7 @@ cleanup_context (CoglDisplay *display)
 }
 
 static CoglBool
-create_context (CoglDisplay *display, GError **error)
+create_context (CoglDisplay *display, CoglError **error)
 {
   CoglDisplayEGL *egl_display = display->winsys;
 
@@ -390,7 +391,7 @@ create_context (CoglDisplay *display, GError **error)
     }
   else
     {
-      g_clear_error (error);
+      _cogl_clear_error (error);
       cleanup_context (display);
       egl_display->stencil_disabled = TRUE;
       return try_create_context (display, FALSE, error);
@@ -416,7 +417,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_display_setup (CoglDisplay *display,
-                            GError **error)
+                            CoglError **error)
 {
   CoglDisplayEGL *egl_display;
   CoglRenderer *renderer = display->renderer;
@@ -455,7 +456,7 @@ error:
 }
 
 static CoglBool
-_cogl_winsys_context_init (CoglContext *context, GError **error)
+_cogl_winsys_context_init (CoglContext *context, CoglError **error)
 {
   CoglRenderer *renderer = context->display->renderer;
   CoglDisplayEGL *egl_display = context->display->winsys;
@@ -513,7 +514,7 @@ typedef struct _CoglGLES2ContextEGL
 } CoglGLES2ContextEGL;
 
 static void *
-_cogl_winsys_context_create_gles2_context (CoglContext *ctx, GError **error)
+_cogl_winsys_context_create_gles2_context (CoglContext *ctx, CoglError **error)
 {
   CoglRendererEGL *egl_renderer = ctx->display->renderer->winsys;
   CoglDisplayEGL *egl_display = ctx->display->winsys;
@@ -530,7 +531,7 @@ _cogl_winsys_context_create_gles2_context (CoglContext *ctx, GError **error)
                                   attribs);
   if (egl_context == EGL_NO_CONTEXT)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_GLES2_CONTEXT,
                    "%s", get_error_string ());
       return NULL;
@@ -556,7 +557,7 @@ _cogl_winsys_destroy_gles2_context (CoglGLES2Context *gles2_ctx)
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -584,7 +585,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
                             &config_count);
   if (status != EGL_TRUE || config_count == 0)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "Failed to find a suitable EGL configuration");
       return FALSE;
@@ -768,7 +769,7 @@ _cogl_winsys_save_context (CoglContext *ctx)
 }
 
 static CoglBool
-_cogl_winsys_set_gles2_context (CoglGLES2Context *gles2_ctx, GError **error)
+_cogl_winsys_set_gles2_context (CoglGLES2Context *gles2_ctx, CoglError **error)
 {
   CoglContext *ctx = gles2_ctx->context;
   CoglDisplayEGL *egl_display = ctx->display->winsys;
@@ -787,7 +788,7 @@ _cogl_winsys_set_gles2_context (CoglGLES2Context *gles2_ctx, GError **error)
 
   if (!status)
     {
-      g_set_error (error,
+      _cogl_set_error (error,
                    COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_MAKE_CURRENT,
                    "Failed to make gles2 context current");
diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c
index 8fc9b71..5b016ec 100644
--- a/cogl/winsys/cogl-winsys-glx.c
+++ b/cogl/winsys/cogl-winsys-glx.c
@@ -48,6 +48,7 @@
 #include "cogl-xlib-renderer.h"
 #include "cogl-util.h"
 #include "cogl-winsys-glx-private.h"
+#include "cogl-error-private.h"
 
 #include <stdlib.h>
 #include <sys/types.h>
@@ -261,7 +262,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 resolve_core_glx_functions (CoglRenderer *renderer,
-                            GError **error)
+                            CoglError **error)
 {
   CoglGLXRenderer *glx_renderer;
 
@@ -306,7 +307,7 @@ resolve_core_glx_functions (CoglRenderer *renderer,
        !g_module_symbol (glx_renderer->libgl_module, "glXGetProcAddressARB",
                          (void **) &glx_renderer->glXGetProcAddress)))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Failed to resolve required GLX symbol");
       return FALSE;
@@ -317,7 +318,7 @@ resolve_core_glx_functions (CoglRenderer *renderer,
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   CoglGLXRenderer *glx_renderer;
   CoglXlibRenderer *xlib_renderer;
@@ -332,7 +333,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
 
   if (renderer->driver != COGL_DRIVER_GL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "GLX Backend can only be used in conjunction with OpenGL");
       goto error;
@@ -343,7 +344,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
 
   if (glx_renderer->libgl_module == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "Failed to dynamically open the OpenGL library");
       goto error;
@@ -356,7 +357,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
                                         &glx_renderer->glx_error_base,
                                         &glx_renderer->glx_event_base))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "XServer appears to lack required GLX support");
       goto error;
@@ -370,7 +371,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
                                       &glx_renderer->glx_minor)
       || !(glx_renderer->glx_major == 1 && glx_renderer->glx_minor >= 2))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "XServer appears to lack required GLX 1.2 support");
       goto error;
@@ -386,7 +387,7 @@ error:
 }
 
 static CoglBool
-update_winsys_features (CoglContext *context, GError **error)
+update_winsys_features (CoglContext *context, CoglError **error)
 {
   CoglGLXDisplay *glx_display = context->display->winsys;
   CoglXlibRenderer *xlib_renderer =
@@ -537,7 +538,7 @@ static CoglBool
 find_fbconfig (CoglDisplay *display,
                CoglFramebufferConfig *config,
                GLXFBConfig *config_ret,
-               GError **error)
+               CoglError **error)
 {
   CoglXlibRenderer *xlib_renderer =
     _cogl_xlib_renderer_get_data (display->renderer);
@@ -556,7 +557,7 @@ find_fbconfig (CoglDisplay *display,
                                              &n_configs);
   if (!configs || n_configs == 0)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Failed to find any compatible fbconfigs");
       ret = FALSE;
@@ -586,7 +587,7 @@ find_fbconfig (CoglDisplay *display,
             }
         }
 
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to find fbconfig with rgba visual");
       ret = FALSE;
@@ -604,7 +605,7 @@ done:
 }
 
 static CoglBool
-create_context (CoglDisplay *display, GError **error)
+create_context (CoglDisplay *display, CoglError **error)
 {
   CoglGLXDisplay *glx_display = display->winsys;
   CoglXlibRenderer *xlib_renderer =
@@ -613,7 +614,7 @@ create_context (CoglDisplay *display, GError **error)
   CoglBool support_transparent_windows =
     display->onscreen_template->config.swap_chain->has_alpha;
   GLXFBConfig config;
-  GError *fbconfig_error = NULL;
+  CoglError *fbconfig_error = NULL;
   XSetWindowAttributes attrs;
   XVisualInfo *xvisinfo;
   GLXDrawable dummy_drawable;
@@ -626,11 +627,11 @@ create_context (CoglDisplay *display, GError **error)
                    &fbconfig_error);
   if (!glx_display->found_fbconfig)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to find suitable fbconfig for the GLX context: %s",
                    fbconfig_error->message);
-      g_error_free (fbconfig_error);
+      cogl_error_free (fbconfig_error);
       return FALSE;
     }
 
@@ -648,7 +649,7 @@ create_context (CoglDisplay *display, GError **error)
                                        True);
   if (glx_display->glx_context == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to create suitable GL context");
       return FALSE;
@@ -669,7 +670,7 @@ create_context (CoglDisplay *display, GError **error)
                                                      config);
   if (xvisinfo == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to retrieve the X11 visual");
       return FALSE;
@@ -724,7 +725,7 @@ create_context (CoglDisplay *display, GError **error)
 
   if (_cogl_xlib_renderer_untrap_errors (display->renderer, &old_state))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to select the newly created GLX context");
       return FALSE;
@@ -771,7 +772,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_display_setup (CoglDisplay *display,
-                            GError **error)
+                            CoglError **error)
 {
   CoglGLXDisplay *glx_display;
   int i;
@@ -795,7 +796,7 @@ error:
 }
 
 static CoglBool
-_cogl_winsys_context_init (CoglContext *context, GError **error)
+_cogl_winsys_context_init (CoglContext *context, CoglError **error)
 {
   context->winsys = g_new0 (CoglContextGLX, 1);
 
@@ -816,7 +817,7 @@ _cogl_winsys_context_deinit (CoglContext *context)
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -829,7 +830,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
   CoglOnscreenXlib *xlib_onscreen;
   CoglOnscreenGLX *glx_onscreen;
   GLXFBConfig fbconfig;
-  GError *fbconfig_error = NULL;
+  CoglError *fbconfig_error = NULL;
 
   _COGL_RETURN_VAL_IF_FAIL (glx_display->glx_context, FALSE);
 
@@ -837,11 +838,11 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
                       &fbconfig,
                       &fbconfig_error))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to find suitable fbconfig for the GLX context: %s",
                    fbconfig_error->message);
-      g_error_free (fbconfig_error);
+      cogl_error_free (fbconfig_error);
       return FALSE;
     }
 
@@ -885,7 +886,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
         {
           char message[1000];
           XGetErrorText (xlib_renderer->xdpy, xerror, message, sizeof(message));
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "Unable to query geometry of foreign xid 0x%08lX: %s",
                        xwin, message);
@@ -919,7 +920,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
                                                          fbconfig);
       if (xvisinfo == NULL)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "Unable to retrieve the X11 visual of context's "
                        "fbconfig");
@@ -958,7 +959,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
           char message[1000];
           XGetErrorText (xlib_renderer->xdpy, xerror,
                          message, sizeof (message));
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "X error while creating Window for CoglOnscreen: %s",
                        message);
@@ -1110,7 +1111,7 @@ _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
 
   XSync (xlib_renderer->xdpy, False);
 
-  /* FIXME: We should be reporting a GError here
+  /* FIXME: We should be reporting a CoglError here
    */
   if (_cogl_xlib_renderer_untrap_errors (context->display->renderer,
                                          &old_state))
@@ -1905,7 +1906,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
   if (glx_tex_pixmap->glx_tex == NULL)
     {
       CoglPixelFormat texture_format;
-      GError *error = NULL;
+      CoglError *error = NULL;
 
       texture_format = (tex_pixmap->depth >= 32 ?
                         COGL_PIXEL_FORMAT_RGBA_8888_PRE :
@@ -1928,7 +1929,7 @@ _cogl_winsys_texture_pixmap_x11_update (CoglTexturePixmapX11 *tex_pixmap,
               COGL_NOTE (TEXTURE_PIXMAP, "Falling back for %p because a "
                          "texture rectangle could not be created: %s",
                          tex_pixmap, error->message);
-              g_error_free (error);
+              cogl_error_free (error);
               free_glx_pixmap (ctx, glx_tex_pixmap);
               return FALSE;
             }
diff --git a/cogl/winsys/cogl-winsys-private.h b/cogl/winsys/cogl-winsys-private.h
index 3262d2f..2ccf20c 100644
--- a/cogl/winsys/cogl-winsys-private.h
+++ b/cogl/winsys/cogl-winsys-private.h
@@ -43,10 +43,10 @@
 
 #include "cogl-poll.h"
 
-GQuark
-_cogl_winsys_error_quark (void);
+uint32_t
+_cogl_winsys_error_domain (void);
 
-#define COGL_WINSYS_ERROR (_cogl_winsys_error_quark ())
+#define COGL_WINSYS_ERROR (_cogl_winsys_error_domain ())
 
 typedef enum { /*< prefix=COGL_WINSYS_ERROR >*/
   COGL_WINSYS_ERROR_INIT,
@@ -78,28 +78,28 @@ typedef struct _CoglWinsysVtable
                                 CoglBool in_core);
 
   CoglBool
-  (*renderer_connect) (CoglRenderer *renderer, GError **error);
+  (*renderer_connect) (CoglRenderer *renderer, CoglError **error);
 
   void
   (*renderer_disconnect) (CoglRenderer *renderer);
 
   CoglBool
-  (*display_setup) (CoglDisplay *display, GError **error);
+  (*display_setup) (CoglDisplay *display, CoglError **error);
 
   void
   (*display_destroy) (CoglDisplay *display);
 
   CoglBool
-  (*context_init) (CoglContext *context, GError **error);
+  (*context_init) (CoglContext *context, CoglError **error);
 
   void
   (*context_deinit) (CoglContext *context);
 
   void *
-  (*context_create_gles2_context) (CoglContext *ctx, GError **error);
+  (*context_create_gles2_context) (CoglContext *ctx, CoglError **error);
 
   CoglBool
-  (*onscreen_init) (CoglOnscreen *onscreen, GError **error);
+  (*onscreen_init) (CoglOnscreen *onscreen, CoglError **error);
 
   void
   (*onscreen_deinit) (CoglOnscreen *onscreen);
@@ -176,7 +176,7 @@ typedef struct _CoglWinsysVtable
   (*save_context) (CoglContext *ctx);
 
   CoglBool
-  (*set_gles2_context) (CoglGLES2Context *gles2_ctx, GError **error);
+  (*set_gles2_context) (CoglGLES2Context *gles2_ctx, CoglError **error);
 
   void
   (*restore_context) (CoglContext *ctx);
diff --git a/cogl/winsys/cogl-winsys-sdl.c b/cogl/winsys/cogl-winsys-sdl.c
index 9d27984..8def1a9 100644
--- a/cogl/winsys/cogl-winsys-sdl.c
+++ b/cogl/winsys/cogl-winsys-sdl.c
@@ -37,6 +37,7 @@
 #include "cogl-context-private.h"
 #include "cogl-onscreen-private.h"
 #include "cogl-winsys-sdl-private.h"
+#include "cogl-error-private.h"
 
 typedef struct _CoglRendererSdl
 {
@@ -84,12 +85,12 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
 #ifndef COGL_HAS_SDL_GLES_SUPPORT
   if (renderer->driver != COGL_DRIVER_GL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "The SDL winsys only supports the GL driver");
       return FALSE;
@@ -98,7 +99,7 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
 
   if (SDL_Init (SDL_INIT_VIDEO) == -1)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "SDL_Init failed: %s",
                    SDL_GetError ());
@@ -143,7 +144,7 @@ set_gl_attribs_from_framebuffer_config (CoglFramebufferConfig *config)
 
 static CoglBool
 _cogl_winsys_display_setup (CoglDisplay *display,
-                            GError **error)
+                            CoglError **error)
 {
   CoglDisplaySdl *sdl_display;
 
@@ -188,7 +189,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
 
   if (sdl_display->surface == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "SDL_SetVideoMode failed: %s",
                    SDL_GetError ());
@@ -236,7 +237,7 @@ sdl_event_filter_cb (SDL_Event *event, void *data)
 }
 
 static CoglBool
-_cogl_winsys_context_init (CoglContext *context, GError **error)
+_cogl_winsys_context_init (CoglContext *context, CoglError **error)
 {
   CoglRenderer *renderer = context->display->renderer;
 
@@ -273,7 +274,7 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -283,7 +284,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
 
   if (sdl_display->onscreen)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "SDL winsys only supports a single onscreen window");
       return FALSE;
@@ -302,7 +303,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
 
       if (sdl_display->surface == NULL)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "SDL_SetVideoMode failed: %s",
                        SDL_GetError ());
diff --git a/cogl/winsys/cogl-winsys-sdl2.c b/cogl/winsys/cogl-winsys-sdl2.c
index f9b94e9..390ab2b 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -86,11 +86,11 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   if (SDL_VideoInit (NULL) < 0)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "SDL_Init failed: %s",
                    SDL_GetError ());
@@ -139,7 +139,7 @@ set_gl_attribs_from_framebuffer_config (CoglFramebufferConfig *config)
 
 static CoglBool
 _cogl_winsys_display_setup (CoglDisplay *display,
-                            GError **error)
+                            CoglError **error)
 {
   CoglDisplaySdl2 *sdl_display;
   const char * (* get_string_func) (GLenum name);
@@ -166,7 +166,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
                                                 SDL_WINDOW_HIDDEN);
   if (sdl_display->dummy_window == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "SDL_CreateWindow failed: %s",
                    SDL_GetError ());
@@ -177,7 +177,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
 
   if (sdl_display->context == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_INIT,
                    "SDL_GL_CreateContext failed: %s",
                    SDL_GetError ());
@@ -198,7 +198,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
        * it's normal GL */
       if (!g_ascii_isdigit (gl_version[0]))
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_INIT,
                        "The GL driver was requested but SDL is using GLES");
           goto error;
@@ -208,7 +208,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
     case COGL_DRIVER_GLES2:
       if (!g_str_has_prefix (gl_version, "OpenGL ES 2"))
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_INIT,
                        "The GLES2 driver was requested but SDL is "
                        "not using GLES2");
@@ -219,7 +219,7 @@ _cogl_winsys_display_setup (CoglDisplay *display,
     case COGL_DRIVER_GLES1:
       if (!g_str_has_prefix (gl_version, "OpenGL ES 1"))
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_INIT,
                        "The GLES1 driver was requested but SDL is "
                        "not using GLES1");
@@ -239,7 +239,7 @@ error:
 }
 
 static CoglBool
-_cogl_winsys_context_init (CoglContext *context, GError **error)
+_cogl_winsys_context_init (CoglContext *context, CoglError **error)
 {
   CoglRenderer *renderer = context->display->renderer;
 
@@ -320,7 +320,7 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglOnscreenSdl2 *sdl_onscreen;
@@ -338,7 +338,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
 
   if (window == NULL)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "SDL_CreateWindow failed: %s",
                    SDL_GetError ());
diff --git a/cogl/winsys/cogl-winsys-stub.c b/cogl/winsys/cogl-winsys-stub.c
index 2648622..aee70a9 100644
--- a/cogl/winsys/cogl-winsys-stub.c
+++ b/cogl/winsys/cogl-winsys-stub.c
@@ -76,7 +76,7 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   renderer->winsys = &_cogl_winsys_stub_dummy_ptr;
   return TRUE;
@@ -90,14 +90,14 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_display_setup (CoglDisplay *display,
-                            GError **error)
+                            CoglError **error)
 {
   display->winsys = &_cogl_winsys_stub_dummy_ptr;
   return TRUE;
 }
 
 static CoglBool
-_cogl_winsys_context_init (CoglContext *context, GError **error)
+_cogl_winsys_context_init (CoglContext *context, CoglError **error)
 {
   context->winsys = &_cogl_winsys_stub_dummy_ptr;
 
@@ -117,7 +117,7 @@ _cogl_winsys_context_deinit (CoglContext *context)
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   return TRUE;
 }
diff --git a/cogl/winsys/cogl-winsys-wgl.c b/cogl/winsys/cogl-winsys-wgl.c
index 418e728..7e2dc5d 100644
--- a/cogl/winsys/cogl-winsys-wgl.c
+++ b/cogl/winsys/cogl-winsys-wgl.c
@@ -232,7 +232,7 @@ win32_event_filter_cb (MSG *msg, void *data)
 
 static CoglBool
 _cogl_winsys_renderer_connect (CoglRenderer *renderer,
-                               GError **error)
+                               CoglError **error)
 {
   renderer->winsys = g_slice_new0 (CoglRendererWgl);
 
@@ -372,7 +372,7 @@ choose_pixel_format (CoglFramebufferConfig *config,
 }
 
 static CoglBool
-create_window_class (CoglDisplay *display, GError **error)
+create_window_class (CoglDisplay *display, CoglError **error)
 {
   CoglDisplayWgl *wgl_display = display->winsys;
   char *class_name_ascii, *src;
@@ -415,7 +415,7 @@ create_window_class (CoglDisplay *display, GError **error)
 
   if (wgl_display->window_class == 0)
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_CONTEXT,
                    "Unable to register window class");
       return FALSE;
@@ -425,7 +425,7 @@ create_window_class (CoglDisplay *display, GError **error)
 }
 
 static CoglBool
-create_context (CoglDisplay *display, GError **error)
+create_context (CoglDisplay *display, CoglError **error)
 {
   CoglDisplayWgl *wgl_display = display->winsys;
 
@@ -451,7 +451,7 @@ create_context (CoglDisplay *display, GError **error)
 
       if (wgl_display->dummy_hwnd == NULL)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_CONTEXT,
                        "Unable to create dummy window");
           return FALSE;
@@ -470,7 +470,7 @@ create_context (CoglDisplay *display, GError **error)
 
       if (pf == 0 || !SetPixelFormat (wgl_display->dummy_dc, pf, &pfd))
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_CONTEXT,
                        "Unable to find suitable GL pixel format");
           ReleaseDC (wgl_display->dummy_hwnd, wgl_display->dummy_dc);
@@ -485,7 +485,7 @@ create_context (CoglDisplay *display, GError **error)
 
       if (wgl_display->wgl_context == NULL)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_CONTEXT,
                        "Unable to create suitable GL context");
           return FALSE;
@@ -529,7 +529,7 @@ _cogl_winsys_display_destroy (CoglDisplay *display)
 
 static CoglBool
 _cogl_winsys_display_setup (CoglDisplay *display,
-                            GError **error)
+                            CoglError **error)
 {
   CoglDisplayWgl *wgl_display;
 
@@ -587,7 +587,7 @@ get_wgl_extensions_string (HDC dc)
 }
 
 static CoglBool
-update_winsys_features (CoglContext *context, GError **error)
+update_winsys_features (CoglContext *context, CoglError **error)
 {
   CoglDisplayWgl *wgl_display = context->display->winsys;
   CoglRendererWgl *wgl_renderer = context->display->renderer->winsys;
@@ -633,7 +633,7 @@ update_winsys_features (CoglContext *context, GError **error)
 }
 
 static CoglBool
-_cogl_winsys_context_init (CoglContext *context, GError **error)
+_cogl_winsys_context_init (CoglContext *context, CoglError **error)
 {
   CoglContextWgl *wgl_context;
 
@@ -733,7 +733,7 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
 
 static CoglBool
 _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
-                            GError **error)
+                            CoglError **error)
 {
   CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = framebuffer->context;
@@ -789,7 +789,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
 
       if (hwnd == NULL)
         {
-          g_set_error (error, COGL_WINSYS_ERROR,
+          _cogl_set_error (error, COGL_WINSYS_ERROR,
                        COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                        "Unable to create window");
           return FALSE;
@@ -814,7 +814,7 @@ _cogl_winsys_onscreen_init (CoglOnscreen *onscreen,
 
   if (pf == 0 || !SetPixelFormat (wgl_onscreen->client_dc, pf, &pfd))
     {
-      g_set_error (error, COGL_WINSYS_ERROR,
+      _cogl_set_error (error, COGL_WINSYS_ERROR,
                    COGL_WINSYS_ERROR_CREATE_ONSCREEN,
                    "Error setting pixel format on the window");
 
diff --git a/cogl/winsys/cogl-winsys.c b/cogl/winsys/cogl-winsys.c
index c6bcdde..dadabd5 100644
--- a/cogl/winsys/cogl-winsys.c
+++ b/cogl/winsys/cogl-winsys.c
@@ -30,8 +30,8 @@
 
 #include <gmodule.h>
 
-GQuark
-_cogl_winsys_error_quark (void)
+uint32_t
+_cogl_winsys_error_domain (void)
 {
   return g_quark_from_static_string ("cogl-winsys-error-quark");
 }
diff --git a/doc/reference/cogl2/cogl2-docs.xml.in b/doc/reference/cogl2/cogl2-docs.xml.in
index d088c3a..bff1613 100644
--- a/doc/reference/cogl2/cogl2-docs.xml.in
+++ b/doc/reference/cogl2/cogl2-docs.xml.in
@@ -62,6 +62,7 @@
     </section>
 
     <xi:include href="xml/cogl-object.xml"/>
+    <xi:include href="xml/cogl-error.xml"/>
     <xi:include href="xml/cogl-context.xml"/>
     <xi:include href="xml/cogl-poll.xml"/>
 
diff --git a/doc/reference/cogl2/cogl2-sections.txt b/doc/reference/cogl2/cogl2-sections.txt
index 0193a9c..91ded8c 100644
--- a/doc/reference/cogl2/cogl2-sections.txt
+++ b/doc/reference/cogl2/cogl2-sections.txt
@@ -11,6 +11,16 @@ cogl_object_set_user_data
 </SECTION>
 
 <SECTION>
+<FILE>cogl-error</FILE>
+<TITLE>Exception handling</TITLE>
+CoglError
+cogl_error_matches
+cogl_error_free
+cogl_error_copy
+COGL_GLIB_ERROR
+</SECTION>
+
+<SECTION>
 <FILE>cogl-renderer</FILE>
 <TITLE>CoglRenderer: Connect to a backend renderer</TITLE>
 cogl_renderer_new
@@ -631,7 +641,7 @@ cogl_pipeline_add_layer_snippet
 
 <SUBSECTION Private>
 cogl_blend_string_error_get_type
-cogl_blend_string_error_quark
+cogl_blend_string_error_domain
 </SECTION>
 
 <SECTION>
diff --git a/examples/android/hello/jni/main.c b/examples/android/hello/jni/main.c
index dacbbab..2c5bd9b 100644
--- a/examples/android/hello/jni/main.c
+++ b/examples/android/hello/jni/main.c
@@ -40,7 +40,7 @@ typedef struct
 static int test_init (TestData* data)
 {
   CoglOnscreen *onscreen;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglVertexP2C4 triangle_vertices[] = {
         {0, 0.7, 0xff, 0x00, 0x00, 0x80},
         {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index 2b6c83e..6fd47ae 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -145,7 +145,7 @@ main (int argc, char **argv)
   CoglContext *ctx;
   CoglOnscreen *onscreen;
   CoglFramebuffer *fb;
-  GError *error = NULL;
+  CoglError *error = NULL;
   Data data;
   PangoRectangle hello_label_size;
   float fovy, aspect, z_near, z_2d, z_far;
diff --git a/examples/cogl-gles2-context.c b/examples/cogl-gles2-context.c
index 408852a..70aed2f 100644
--- a/examples/cogl-gles2-context.c
+++ b/examples/cogl-gles2-context.c
@@ -23,7 +23,7 @@ static gboolean
 paint_cb (void *user_data)
 {
     Data *data = user_data;
-    GError *error = NULL;
+    CoglError *error = NULL;
     const CoglGLES2Vtable *gles2 = data->gles2_vtable;
 
     /* Draw scene with GLES2 */
@@ -71,7 +71,7 @@ main (int argc, char **argv)
 {
     Data data;
     CoglOnscreen *onscreen;
-    GError *error = NULL;
+    CoglError *error = NULL;
     CoglVertexP2C4 triangle_vertices[] = {
         {0, 0.7, 0xff, 0x00, 0x00, 0x80},
         {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
diff --git a/examples/cogl-gles2-gears.c b/examples/cogl-gles2-gears.c
index 2952ca6..e69447c 100644
--- a/examples/cogl-gles2-gears.c
+++ b/examples/cogl-gles2-gears.c
@@ -560,7 +560,7 @@ paint_cb (void *user_data)
     Data *data = user_data;
     double elapsed = g_timer_elapsed (data->timer, NULL);
     double dt = elapsed - data->last_elapsed;
-    GError *error = NULL;
+    CoglError *error = NULL;
 
     /* Draw scene with GLES2 */
     if (!cogl_push_gles2_context (data->ctx,
@@ -755,7 +755,7 @@ main (int argc, char **argv)
 {
     Data data;
     CoglOnscreen *onscreen;
-    GError *error = NULL;
+    CoglError *error = NULL;
     GSource *cogl_source;
     GMainLoop *loop;
     CoglRenderer *renderer;
diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c
index cf0e8f6..f8265f9 100644
--- a/examples/cogl-hello.c
+++ b/examples/cogl-hello.c
@@ -40,7 +40,7 @@ main (int argc, char **argv)
 {
     Data data;
     CoglOnscreen *onscreen;
-    GError *error = NULL;
+    CoglError *error = NULL;
     CoglVertexP2C4 triangle_vertices[] = {
         {0, 0.7, 0xff, 0x00, 0x00, 0x80},
         {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
diff --git a/examples/cogl-info.c b/examples/cogl-info.c
index b7dab00..c576dbb 100644
--- a/examples/cogl-info.c
+++ b/examples/cogl-info.c
@@ -164,7 +164,7 @@ main (int argc, char **argv)
   CoglRenderer *renderer;
   CoglDisplay *display;
   CoglContext *ctx;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglWinsysID winsys_id;
   const char *winsys_name;
 
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index 99f9b8d..73f9c4e 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -10,7 +10,7 @@ main (int argc, char **argv)
     CoglContext *ctx;
     CoglOnscreen *onscreen;
     CoglFramebuffer *fb;
-    GError *error = NULL;
+    CoglError *error = NULL;
     CoglVertexP2C4 triangle_vertices[] = {
         {0, 0.7, 0xff, 0x00, 0x00, 0x80},
         {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
@@ -49,7 +49,7 @@ main (int argc, char **argv)
       {
         fprintf (stderr, "Failed to allocate 4x msaa offscreen framebuffer, "
                  "disabling msaa for onscreen rendering: %s\n", error->message);
-        g_error_free (error);
+        cogl_error_free (error);
         cogl_framebuffer_set_samples_per_pixel (fb, 0);
 
         error = NULL;
@@ -70,7 +70,7 @@ main (int argc, char **argv)
     cogl_framebuffer_set_samples_per_pixel (offscreen_fb, 4);
     if (!cogl_framebuffer_allocate (offscreen_fb, &error))
       {
-        g_error_free (error);
+        cogl_error_free (error);
         error = NULL;
         fprintf (stderr, "Failed to allocate 4x msaa offscreen framebuffer, "
                  "disabling msaa for offscreen rendering");
diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c
index 1525deb..41b99af 100644
--- a/examples/cogl-sdl-hello.c
+++ b/examples/cogl-sdl-hello.c
@@ -68,7 +68,7 @@ main (int argc, char **argv)
 {
   CoglContext *ctx;
   CoglOnscreen *onscreen;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglVertexP2C4 triangle_vertices[] = {
     {0, 0.7, 0xff, 0x00, 0x00, 0x80},
     {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
diff --git a/examples/cogl-sdl2-hello.c b/examples/cogl-sdl2-hello.c
index f465771..5df40ab 100644
--- a/examples/cogl-sdl2-hello.c
+++ b/examples/cogl-sdl2-hello.c
@@ -77,7 +77,7 @@ main (int argc, char **argv)
 {
   CoglContext *ctx;
   CoglOnscreen *onscreen;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglVertexP2C4 triangle_vertices[] = {
     {0, 0.7, 0xff, 0x00, 0x00, 0x80},
     {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c
index 9397f4d..ca9e3ed 100644
--- a/examples/cogl-x11-foreign.c
+++ b/examples/cogl-x11-foreign.c
@@ -53,7 +53,7 @@ main (int argc, char **argv)
   CoglOnscreen *onscreen;
   CoglFramebuffer *fb;
   CoglPipeline *pipeline;
-  GError *error = NULL;
+  CoglError *error = NULL;
   uint32_t visual;
   XVisualInfo template, *xvisinfo;
   int visinfos_count;
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index f71bf2a..b59327c 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -49,7 +49,7 @@ main (int argc, char **argv)
   CoglContext *ctx;
   CoglOnscreen *onscreen;
   CoglFramebuffer *fb;
-  GError *error = NULL;
+  CoglError *error = NULL;
   uint32_t visual;
   XVisualInfo template, *xvisinfo;
   int visinfos_count;
diff --git a/examples/cogland.c b/examples/cogland.c
index 849ec9a..acbeda0 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -299,7 +299,7 @@ cogland_surface_attach_buffer (struct wl_client *wayland_client,
 
   if (!buffer->texture)
     {
-      GError *error = NULL;
+      CoglError *error = NULL;
 
       buffer->texture =
         cogl_wayland_texture_2d_new_from_buffer (compositor->cogl_context,
@@ -453,7 +453,7 @@ cogland_compositor_create_output (CoglandCompositor *compositor,
 {
   CoglandOutput *output = g_slice_new0 (CoglandOutput);
   CoglFramebuffer *fb;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglandMode *mode;
 
   output->x = x;
@@ -689,7 +689,7 @@ main (int argc, char **argv)
 {
   CoglandCompositor compositor;
   GMainLoop *loop;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglVertexP2C4 triangle_vertices[] = {
       {0, 0.7, 0xff, 0x00, 0x00, 0x80},
       {-0.7, -0.7, 0x00, 0xff, 0x00, 0xff},
diff --git a/tests/conform/test-blend-strings.c b/tests/conform/test-blend-strings.c
index ad11109..5907428 100644
--- a/tests/conform/test-blend-strings.c
+++ b/tests/conform/test-blend-strings.c
@@ -54,7 +54,7 @@ test_blend (TestState *state,
 
   CoglPipeline *pipeline;
   CoglBool status;
-  GError *error = NULL;
+  CoglError *error = NULL;
   int y_off;
   int x_off;
 
@@ -178,7 +178,7 @@ test_tex_combine (TestState *state,
 
   CoglPipeline *pipeline;
   CoglBool status;
-  GError *error = NULL;
+  CoglError *error = NULL;
   int y_off;
   int x_off;
 
diff --git a/tests/conform/test-gles2-context.c b/tests/conform/test-gles2-context.c
index a55920b..9a3c8b6 100644
--- a/tests/conform/test-gles2-context.c
+++ b/tests/conform/test-gles2-context.c
@@ -21,7 +21,7 @@ test_push_pop_single_context (void)
   CoglPipeline *pipeline;
   CoglGLES2Context *gles2_ctx;
   const CoglGLES2Vtable *gles2;
-  GError *error = NULL;
+  CoglError *error = NULL;
 
   offscreen_texture = COGL_TEXTURE (
     cogl_texture_2d_new_with_size (test_ctx,
@@ -146,7 +146,7 @@ create_gles2_context (CoglTexture **offscreen_texture,
                       CoglGLES2Context **gles2_ctx,
                       const CoglGLES2Vtable **gles2)
 {
-  GError *error = NULL;
+  CoglError *error = NULL;
 
   *offscreen_texture = COGL_TEXTURE (
     cogl_texture_2d_new_with_size (test_ctx,
@@ -179,7 +179,7 @@ test_push_pop_multi_context (void)
   CoglPipeline *pipeline1;
   CoglGLES2Context *gles2_ctx1;
   const CoglGLES2Vtable *gles21;
-  GError *error = NULL;
+  CoglError *error = NULL;
 
   create_gles2_context (&offscreen_texture0,
                         &offscreen0,
@@ -278,7 +278,7 @@ test_gles2_read_pixels (void)
   CoglPipeline *pipeline;
   CoglGLES2Context *gles2_ctx;
   const CoglGLES2Vtable *gles2;
-  GError *error = NULL;
+  CoglError *error = NULL;
   GLubyte pixel[3];
   GLuint fbo_handle;
 
@@ -684,7 +684,7 @@ test_gles2_context_fbo (void)
       CoglPipeline *pipeline;
       CoglGLES2Context *gles2_ctx;
       GLuint program;
-      GError *error = NULL;
+      CoglError *error = NULL;
 
       create_gles2_context (&offscreen_texture,
                             &offscreen,
@@ -814,7 +814,7 @@ test_gles2_context_copy_tex_image (void)
   CoglPipeline *pipeline;
   CoglGLES2Context *gles2_ctx;
   const CoglGLES2Vtable *gles2;
-  GError *error = NULL;
+  CoglError *error = NULL;
   GLuint tex;
   GLint tex_uniform_location;
   GLint pos_location;
diff --git a/tests/conform/test-just-vertex-shader.c b/tests/conform/test-just-vertex-shader.c
index aa65996..090bf27 100644
--- a/tests/conform/test-just-vertex-shader.c
+++ b/tests/conform/test-just-vertex-shader.c
@@ -29,7 +29,7 @@ paint (TestState *state)
 {
   CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
   CoglTexture *tex;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglSnippet *snippet;
 
   cogl_framebuffer_clear4f (test_fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
diff --git a/tests/conform/test-multitexture.c b/tests/conform/test-multitexture.c
index aeb409c..6eab806 100644
--- a/tests/conform/test-multitexture.c
+++ b/tests/conform/test-multitexture.c
@@ -104,7 +104,7 @@ on_paint (ClutterActor *actor, TestState *state)
   CoglHandle tex0, tex1;
   CoglHandle material;
   CoglBool status;
-  GError *error = NULL;
+  CoglError *error = NULL;
   float tex_coords[] = {
     0, 0, 0.5, 0.5, /* tex0 */
     0.5, 0.5, 1, 1 /* tex1 */
diff --git a/tests/conform/test-pipeline-user-matrix.c b/tests/conform/test-pipeline-user-matrix.c
index 6fe6187..9a7beea 100644
--- a/tests/conform/test-pipeline-user-matrix.c
+++ b/tests/conform/test-pipeline-user-matrix.c
@@ -55,7 +55,7 @@ paint (TestState *state)
   CoglTexture *tex0, *tex1;
   CoglPipeline *pipeline;
   CoglMatrix matrix;
-  GError *error = NULL;
+  CoglError *error = NULL;
 
   cogl_framebuffer_orthographic (test_fb,
                                  0, 0,
diff --git a/tests/conform/test-point-sprite.c b/tests/conform/test-point-sprite.c
index 0cdfdbd..737138f 100644
--- a/tests/conform/test-point-sprite.c
+++ b/tests/conform/test-point-sprite.c
@@ -24,7 +24,7 @@ do_test (CoglBool check_orientation)
   int fb_width = cogl_framebuffer_get_width (test_fb);
   int fb_height = cogl_framebuffer_get_height (test_fb);
   CoglPrimitive *prim;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglTexture2D *tex_2d;
   CoglPipeline *pipeline, *solid_pipeline;
   CoglBool res;
diff --git a/tests/conform/test-sub-texture.c b/tests/conform/test-sub-texture.c
index 22a8873..592690a 100644
--- a/tests/conform/test-sub-texture.c
+++ b/tests/conform/test-sub-texture.c
@@ -31,7 +31,6 @@ create_source (TestState *state)
   int dx, dy;
   uint8_t *data = g_malloc (SOURCE_SIZE * SOURCE_SIZE * 4);
   CoglTexture2D *tex;
-  GError *error = NULL;
 
   /* Create a texture with a different coloured rectangle at each
      corner */
@@ -61,8 +60,7 @@ create_source (TestState *state)
                                        COGL_PIXEL_FORMAT_ANY,
                                        SOURCE_SIZE * 4,
                                        data,
-                                       &error);
-  g_assert_no_error (error);
+                                       NULL);
   return tex;
 }
 
@@ -72,7 +70,6 @@ create_test_texture (TestState *state)
   CoglTexture2D *tex;
   uint8_t *data = g_malloc (256 * 256 * 4), *p = data;
   int x, y;
-  GError *error = NULL;
 
   /* Create a texture that is 256x256 where the red component ranges
      from 0->255 along the x axis and the green component ranges from
@@ -93,9 +90,7 @@ create_test_texture (TestState *state)
                                        COGL_PIXEL_FORMAT_ANY,
                                        256 * 4,
                                        data,
-                                       &error);
-  g_assert_no_error (error);
-
+                                       NULL);
   g_free (data);
 
   return tex;
diff --git a/tests/conform/test-texture-3d.c b/tests/conform/test-texture-3d.c
index c365dc7..3ca1aa5 100644
--- a/tests/conform/test-texture-3d.c
+++ b/tests/conform/test-texture-3d.c
@@ -24,7 +24,7 @@ create_texture_3d (CoglContext *context)
   uint8_t *data = g_malloc (TEX_IMAGE_STRIDE * TEX_DEPTH);
   uint8_t *p = data;
   CoglTexture3D *tex;
-  GError *error = NULL;
+  CoglError *error = NULL;
 
   for (z = 0; z < TEX_DEPTH; z++)
     {
diff --git a/tests/conform/test-utils.c b/tests/conform/test-utils.c
index 5a6e52f..6c55bf7 100644
--- a/tests/conform/test-utils.c
+++ b/tests/conform/test-utils.c
@@ -15,7 +15,7 @@ void
 test_utils_init (TestFlags flags)
 {
   static int counter = 0;
-  GError *error = NULL;
+  CoglError *error = NULL;
   CoglOnscreen *onscreen = NULL;
   CoglDisplay *display;
   CoglRenderer *renderer;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]