[visit-developers] catching exception thrown from VisIt

sveta sveta at txcorp.com
Mon Feb 22 18:17:26 EST 2016


Hello,

I am trying to determine if the plot which we try to add to VisIt does 
not get added.  I did the foloowing:

1.  In ViewerPlotList::GetDefaultSILRestriction I added try/catch block:

try {
       meshName = md->MeshForVar(realvar);
     }
     catch (InvalidVariableException) {

       meshName = "";
       throw;
     }

2.  In ViewerPlotList::NewPlot I also added try/catch block:

try {
       silr = GetDefaultSILRestriction(host, db, newVarName, plotState,
                                     !inheritSILRestriction);
     }
     catch(InvalidVariableException){
       std::cout <<"Exception in getting SIL" << std::endl;
       hadError = 1;
     }
     if (hadError) return 0;

I confirmed that NewPlot returns 0.

3.  Finally in ViewerPlotList::AddPlot I added "throw 100" (when NewPlot 
returns 0) in this block:

    TRY
     {
         newPlot = NewPlot(type, engineKey, hostName, databaseName,
                           var, applyOperators, inheritSILRestriction, 0);
         if (newPlot == 0)
         {
             Error(tr("VisIt could not create the desired plot."));
             hadError = true;
//Tech-X added
             std::cout <<"throwing int" <<std::endl;
             throw 100;
         } else {
             newPlot->SetEmbeddedPlotId(embeddedPlotId);
         }
     }
     CATCH2(VisItException, e)
     {
         Error(e.Message().c_str());
         hadError = true;
     }
     ENDTRY

In composertoolkit, I call try to catch this exception:

   try {
     viewer->DelayedMethods()->AddEmbeddedPlot(plotCode,
       varName.toStdString(), idCode);
   }
   catch(int e) {
     std::cout<<"exception caught by visit buffer" << std::endl;
     ret = false;
     throw e;
   }

But the exception does not get through (I confirmed by the printout that 
VisIt did throw it).

Any ideas why the exception does not end up in our code?

Thank you,
Sveta









More information about the visit-developers mailing list