+ if (! last_errstring)
+ return NULL;
+
+ if (last_errcode == 0 && ! last_object_name)
+ ret = (char *) last_errstring;
+ else if (last_errcode == 0)
+ ret = (asprintf (&buf, "%s: %s", last_object_name, last_errstring) == -1
+ ? NULL : buf);
+ else if (! last_object_name)
+ ret = (asprintf (&buf, "%s: %s",
+ last_errstring, strerror (last_errcode)) == -1
+ ? NULL : buf);
+ else
+ ret = (asprintf (&buf, "%s: %s: %s",
+ last_object_name, last_errstring,
+ strerror (last_errcode)) == -1
+ ? NULL : buf);
+
+ /* Reset the error indicator. */
+ free (last_errstring);
+ last_errstring = NULL;
+ return ret;