Index: libgimp/gimp.c
===================================================================
--- libgimp/gimp.c	(revision 26596)
+++ libgimp/gimp.c	(working copy)
@@ -156,6 +156,9 @@ static gboolean   gimp_extension_read   
                                                 GIOCondition     condition,
                                                 gpointer         data);
 
+static void       gimp_set_pdb_error           (const GimpParam *return_vals,
+                                                gint             n_return_vals);
+
 
 static GIOChannel *_readchannel  = NULL;
 GIOChannel *_writechannel = NULL;
@@ -189,6 +192,8 @@ static GimpStackTraceMode stack_trace_mo
 
 static GHashTable    *temp_proc_ht       = NULL;
 
+static gchar         *pdb_error_message  = NULL;
+
 static guint          gimp_debug_flags   = 0;
 
 static const GDebugKey gimp_debug_keys[] =
@@ -203,7 +208,6 @@ static const GDebugKey gimp_debug_keys[]
   { "on",             GIMP_DEBUG_DEFAULT        }
 };
 
-
 static GimpPlugInInfo PLUG_IN_INFO;
 
 
@@ -964,22 +968,10 @@ gimp_run_procedure2 (const gchar     *na
   proc_return->nparams = 0;
   proc_return->params  = NULL;
 
-  switch (return_vals[0].data.d_status)
-    {
-    case GIMP_PDB_EXECUTION_ERROR:
-      break;
-
-    case GIMP_PDB_CALLING_ERROR:
-      g_printerr ("a calling error occurred while trying to run: \"%s\"\n",
-                  name);
-      break;
-
-    default:
-      break;
-    }
-
   gimp_wire_destroy (&msg);
 
+  gimp_set_pdb_error (return_vals, *n_return_vals);
+
   return return_vals;
 }
 
@@ -1019,6 +1011,30 @@ gimp_destroy_paramdefs (GimpParamDef *pa
 }
 
 /**
+ * gimp_get_pdb_error:
+ *
+ * Retrieves the error message from the last procedure call.
+ *
+ * If a procedure call fails, then it might pass an error message with
+ * the return values. Plug-ins that are using the libgimp C wrappers
+ * don't access the procedure return values directly. Thus ligimp
+ * stores the error message and makes it available with this
+ * function. A successful procedure call unsets the error message again.
+ *
+ * The returned string should be freed when no longer needed.
+ *
+ * Return value: a newly allocated string, or %NULL if there's no saved
+ *               error message
+ *
+ * Since: GIMP 2.6
+ **/
+gchar *
+gimp_get_pdb_error (void)
+{
+  return g_strdup (pdb_error_message);
+}
+
+/**
  * gimp_tile_width:
  *
  * Returns the tile width GIMP is using.
@@ -1953,3 +1969,30 @@ gimp_extension_read (GIOChannel  *channe
 
   return TRUE;
 }
+
+static void
+gimp_set_pdb_error (const GimpParam *return_vals,
+                    gint             n_return_vals)
+{
+  if (pdb_error_message)
+    {
+      g_free (pdb_error_message);
+      pdb_error_message = NULL;
+    }
+
+  switch (return_vals[0].data.d_status)
+    {
+    case GIMP_PDB_SUCCESS:
+    case GIMP_PDB_PASS_THROUGH:
+      return;
+
+    case GIMP_PDB_EXECUTION_ERROR:
+    case GIMP_PDB_CALLING_ERROR:
+    case GIMP_PDB_CANCEL:
+      if (n_return_vals > 0 && return_vals[1].type == GIMP_PDB_STRING)
+        {
+          pdb_error_message = g_strdup (return_vals[1].data.d_string);
+        }
+      break;
+    }
+}
Index: libgimp/gimp.h
===================================================================
--- libgimp/gimp.h	(revision 26596)
+++ libgimp/gimp.h	(working copy)
@@ -307,6 +307,10 @@ void           gimp_destroy_params      
 void           gimp_destroy_paramdefs   (GimpParamDef    *paramdefs,
                                          gint             n_params);
 
+/* Retrieve the error message (if any) for the last procedure call.
+ */
+gchar        * gimp_get_pdb_error       (void);
+
 
 /* Return various constants given by the GIMP core at plug-in config time.
  */
Index: libgimp/gimp.def
===================================================================
--- libgimp/gimp.def	(revision 26596)
+++ libgimp/gimp.def	(working copy)
@@ -236,6 +236,7 @@ EXPORTS
 	gimp_get_module_load_inhibit
 	gimp_get_monitor_resolution
 	gimp_get_path_by_tattoo
+	gimp_get_pdb_error
 	gimp_get_progname
 	gimp_get_theme_dir
 	gimp_getpid
