diff --git a/regtest/basic/rt-make-threads/main.cpp b/regtest/basic/rt-make-threads/main.cpp index 4e10210ac3..815821f8fe 100644 --- a/regtest/basic/rt-make-threads/main.cpp +++ b/regtest/basic/rt-make-threads/main.cpp @@ -11,23 +11,50 @@ using namespace PLMD; void run(std::ostream & os, const std::string & name,std::function f,unsigned nthreads=4,unsigned nrepeats=10){ + + // vector containing possible error messages from threads + std::vector msgs(nthreads); + + // wrapper function that catch exceptions and store their messages + auto g=[&](int i){ + try { + f(i); + } catch(const std::exception& e) { + char buffer[1024]; + std::sprintf(buffer,"(thread %d)\n",i); + msgs[i]=std::string(buffer)+e.what(); + } + }; + os<<"Test "<0) msg+=msgs[j]; + // one could propagate the exception with plumed_error()<0) os<<"failed with error "< threads; - for(unsigned j=0;j0) msg+=msgs[j]; + if(msg.length()>0) os<<"failed with error "<