diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 21f2317ed52e6faba1e7a426a711d705bb223faf..ebebb4c8a3d8596d5df4ccbacae1c7b04968e8d9 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -332,12 +332,17 @@ def _add_functionality():
 
     def error_str(self):
         val = self.args[0]
-        result = "%s failed: %s" % (val.routine(), 
-                status_code.to_string(val.code(), "<unknown error %d>")
-                .lower().replace("_", " "))
-        if val.what():
-            result += " - " + val.what()
-        return result
+        try:
+            val.routine
+        except AttributeError:
+            return str(val)
+        else:
+            result = "%s failed: %s" % (val.routine(), 
+                    status_code.to_string(val.code(), "<unknown error %d>")
+                    .lower().replace("_", " "))
+            if val.what():
+                result += " - " + val.what()
+            return result
 
     def error_code(self):
         return self.args[0].code()