diff --git a/src/core/PlumedMainInitializer.cpp b/src/core/PlumedMainInitializer.cpp
index adc4c1643fb31e73419ea47329c2831919554684..3651a64f654b6028a1edbcc4b4179a1cd15f0590 100644
--- a/src/core/PlumedMainInitializer.cpp
+++ b/src/core/PlumedMainInitializer.cpp
@@ -153,7 +153,8 @@ extern "C" void plumed_plumedmain_cmd_nothrow(void*plumed,const char*key,const v
   } catch(const std::exception & e) {
     nothrow.handler(nothrow.ptr,10000,e.what(),nullptr);
   } catch(...) {
-    std::cerr<<"+++ rethrowing an unknown error happened while using a plumed cmd"<<std::endl;
+    // if exception cannot be translated, we throw a bad_exception
+    nothrow.handler(nothrow.ptr,11500,"plumed could not translate exception",nullptr);
     throw;
   }
 }
diff --git a/src/wrapper/Plumed.h b/src/wrapper/Plumed.h
index ec42f68e9f41bd112afc8d79368b53ba7aea7d3e..b2495374ca663cf8e09c526038018b8e15b8d2c5 100644
--- a/src/wrapper/Plumed.h
+++ b/src/wrapper/Plumed.h
@@ -1228,7 +1228,7 @@ class Plumed {
     } catch(const ::std::exception & e) {
       throw Plumed::std_exception(e.what());
     } catch(...) {
-      throw;
+      throw Plumed::std_bad_exception("plumed could not translate exception");
     }
   }