@@ -632,8 +632,14 @@ class Concore{
632632 }
633633 }
634634
635- catch (...){
636- cout<<" skipping +" <<outpath<<port<<" /" <<name;
635+ catch (const std::exception &e) {
636+ // Surface the error message and rethrow so callers (or the runtime)
637+ // see the failure instead of silently proceeding with truncated data.
638+ std::cerr << e.what () << std::endl;
639+ throw ;
640+ } catch (...) {
641+ // Unknown exception: rethrow to avoid silent suppression.
642+ throw ;
637643 }
638644 }
639645
@@ -657,8 +663,11 @@ class Concore{
657663 }
658664 else throw 505 ;
659665 }
660- catch (...){
661- cout<<" skipping +" <<outpath<<port<<" /" <<name;
666+ catch (const std::exception &e) {
667+ std::cerr << e.what () << std::endl;
668+ throw ;
669+ } catch (...) {
670+ throw ;
662671 }
663672 }
664673
@@ -683,9 +692,13 @@ class Concore{
683692 outfile<<val[val.size ()-1 ]<<' ]' ;
684693 std::string result = outfile.str ();
685694 if (result.size () >= SHM_SIZE ) {
686- std::cerr << " ERROR: write_SM payload (" << result.size ()
687- << " bytes) exceeds " << SHM_SIZE - 1
688- << " -byte shared memory limit. Data truncated!" << std::endl;
695+ throw std::runtime_error (
696+ " concore SHM write failed: payload (" +
697+ std::to_string (result.size ()) +
698+ " bytes) exceeds SHM_SIZE (" +
699+ std::to_string (SHM_SIZE ) +
700+ " ). Aborting. No data written. Increase SHM_SIZE in concore.hpp."
701+ );
689702 }
690703 std::strncpy (sharedData_create, result.c_str (), SHM_SIZE - 1 );
691704 sharedData_create[SHM_SIZE - 1 ] = ' \0 ' ;
@@ -696,8 +709,11 @@ class Concore{
696709 }
697710 }
698711
699- catch (...){
700- cout<<" skipping +" <<outpath<<port<<" /" <<name;
712+ catch (const std::exception &e) {
713+ std::cerr << e.what () << std::endl;
714+ throw ;
715+ } catch (...) {
716+ throw ;
701717 }
702718 }
703719
@@ -711,22 +727,29 @@ class Concore{
711727 void write_SM (int port, string name, string val, int delta=0 ){
712728 chrono::milliseconds timespan ((int )(2000 *delay));
713729 this_thread::sleep_for (timespan);
730+ if (val.size () >= SHM_SIZE ) {
731+ throw std::runtime_error (
732+ " concore SHM write failed: payload (" +
733+ std::to_string (val.size ()) +
734+ " bytes) exceeds SHM_SIZE (" +
735+ std::to_string (SHM_SIZE ) +
736+ " ). Aborting. No data written. Increase SHM_SIZE in concore.hpp."
737+ );
738+ }
714739 try {
715740 if (shmId_create != -1 ){
716741 if (sharedData_create == nullptr )
717742 throw 506 ;
718- if (val.size () >= SHM_SIZE ) {
719- std::cerr << " ERROR: write_SM payload (" << val.size ()
720- << " bytes) exceeds " << SHM_SIZE - 1
721- << " -byte shared memory limit. Data truncated!" << std::endl;
722- }
723743 std::strncpy (sharedData_create, val.c_str (), SHM_SIZE - 1 );
724744 sharedData_create[SHM_SIZE - 1 ] = ' \0 ' ;
725745 }
726746 else throw 505 ;
727747 }
728- catch (...){
729- cout<<" skipping +" <<outpath<<port<<" /" <<name;
748+ catch (const std::exception &e) {
749+ std::cerr << e.what () << std::endl;
750+ throw ;
751+ } catch (...) {
752+ throw ;
730753 }
731754 }
732755
0 commit comments