diff --git a/awesome.c b/awesome.c
index 0beef8f..32535fa 100644
--- a/awesome.c
+++ b/awesome.c
@@ -236,7 +236,10 @@ xerror(void *data __attribute__ ((unused)),
        xcb_generic_error_t *e)
 {
     xutil_error_t *err = xutil_get_error(e);
+    if(!err)
+        return 0;
 
+    warn("fatal error: request=%s, error=%s\n", err->request_label, err->error_label);
     if(e->error_code == BadWindow
        || (e->error_code == BadMatch && err->request_code == XCB_SET_INPUT_FOCUS)
        || (e->error_code == BadValue && err->request_code == XCB_KILL_CLIENT)
diff --git a/common/xutil.c b/common/xutil.c
index 9cd785b..c123181 100644
--- a/common/xutil.c
+++ b/common/xutil.c
@@ -19,12 +19,14 @@
  *
  */
 
-/* strndup() */
+/* strndup(), asprintf() */
 #define _GNU_SOURCE
 
 #include <xcb/xcb.h>
 #include <xcb/xcb_atom.h>
 
+#include <stdio.h>
+
 #include "common/util.h"
 #include "common/xutil.h"
 
@@ -253,7 +255,7 @@ xutil_error_label[] =
 const char *
 xutil_request_label[] =
 {
-    "XCB_NONE",
+    "None",
     "CreateWindow",
     "ChangeWindowAttributes",
     "GetWindowAttributes",
@@ -386,6 +388,10 @@ xutil_request_label[] =
 xutil_error_t *
 xutil_get_error(const xcb_generic_error_t *e)
 {
+    if(e->response_type != 0)
+        /* This is not an error, this _should_ not happen */
+        return NULL;
+
     xutil_error_t *err = p_new(xutil_error_t, 1);
 
     /*
@@ -393,11 +399,21 @@ xutil_get_error(const xcb_generic_error_t *e)
      * out  how it  works BTW,  seems to  get a  byte in  'pad' member
      * (second byte in second element of the array)
      */
-    err->request_code = (e->response_type == 0 ?
-                         *((uint8_t *) e + 10) : (e->response_type & 0x7f));
-
-    err->request_label = a_strdup(xutil_request_label[err->request_code]);
-    err->error_label = a_strdup(xutil_error_label[e->error_code]);
+    err->request_code = *((uint8_t *) e + 10);
+
+    /* Extensions  generally provide  their  own requests  so we  just
+     * store the request code */
+    if(err->request_code >= (sizeof(xutil_request_label) / sizeof(char *)))
+        asprintf(&err->request_label, "%d", err->request_code);
+    else
+        err->request_label = a_strdup(xutil_request_label[err->request_code]);
+
+    /* Extensions may also define their  own errors, so just store the
+     * error_code */
+    if(e->error_code >= (sizeof(xutil_error_label) / sizeof(char *)))
+        asprintf(&err->error_label, "%d", e->error_code);
+    else
+        err->error_label = a_strdup(xutil_error_label[e->error_code]);
 
     return err;
 }

