[visit-developers] catching exception thrown from VisIt

Svetlana G. Shasharina sveta at txcorp.com
Tue Feb 23 15:38:04 EST 2016


I see many CATCHALLs now in ViewerPlotList::AddPlot  and some do not 
rethrow. I will test which one should rethrow.
Sveta

On 2/23/16 1:23 PM, Svetlana G. Shasharina wrote:
> Hi Brad,
> I tried to catch(...) in composer in hope to get an additional 
> exception added here:
>
> 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;
>         } else {
>             newPlot->SetEmbeddedPlotId(embeddedPlotId);
>         }
>     }
>     CATCH2(VisItException, e)
>     {
>         Error(e.Message().c_str());
>         hadError = true;
>         throw 1000; //ADDITIONAL THROW
>     }
>     ENDTRY
>
> and I cannot catch it.  Does VisIt call catch(...) at some point?
>
> I need to be able to tell when AddPlot fails (it relates to the bug 
> that I reported 2/10/16) but the final function 
> ViewerMethods::AddEmbeddedPlot is void.
>
> Any suggestions?
>
> Thanks,
> Sveta
>
>
>
>
>
> On 2/23/16 11:33 AM, Svetlana G. Shasharina wrote:
>> Hi Brad,
>> This exception was not caught because VisItException was caught 
>> before.  So I my statement below is incorrect.
>> Thank you,
>> Sveta
>>
>> On 2/22/16 5:30 PM, sveta wrote:
>>> Hi Brad,
>>>
>>> I tried Methods and got the same result.
>>> I also tried to catch it within VisIt:
>>>
>>> // 
>>> ****************************************************************************
>>> void
>>> ViewerMethods::AddEmbeddedPlot(int type, const std::string &var, int 
>>> id)
>>> {
>>>   //
>>>   // Set the rpc type and arguments.
>>>   //
>>>   try {
>>> state->GetViewerRPC()->SetRPCType(ViewerRPC::AddEmbeddedPlotRPC);
>>>   }
>>>   catch (int) {
>>>     std::cout <<"state->GetViewerRPC()->SetRPCType got 
>>> exception"<<std::endl;
>>>   }
>>>   try {
>>>     state->GetViewerRPC()->SetPlotType(type);
>>>   }
>>>   catch (int) {
>>>     std::cout <<"state->GetViewerRPC()->SetPlotType got exception" 
>>> << std::endl;
>>>   }
>>>   try {
>>>     state->GetViewerRPC()->SetVariable(var);
>>>   }
>>>   catch(int) {
>>>     std::cout <<"state->GetViewerRPC()->SetVariable got exception" 
>>> <<std::endl;
>>>   }
>>>   try {
>>>     state->GetViewerRPC()->SetEmbeddedPlotId(id);
>>>   }
>>>   catch(int) {
>>>     std::cout <<"state->GetViewerRPC()->SetEmbeddedPlotId got 
>>> exception" << std::endl;
>>>   }
>>>
>>>   //
>>>   // Issue the RPC.
>>>   //
>>>   try {
>>>     state->GetViewerRPC()->Notify();
>>>    }
>>>    catch(int) {
>>>       std::cout <<"state->GetViewerRPC()->Notify got exception" << 
>>> std::endl;
>>>    }
>>> }
>>>
>>> But none of this calls caught an int exception...  I was hoping to 
>>> determine which one would do this so I could track down the return 
>>> value of ViewerPlotList::AddPlot (which returns -1 for the case of 
>>> interest) and make AddEmbeddedPlot function to return an int instead 
>>> of being void. In this case, I can check on its return value in 
>>> composer...
>>>
>>> Thanks,
>>> Sveta
>>>
>>> On 2/22/16 4:22 PM, Brad Whitlock wrote:
>>>> Your use of DelayedMethods will queue up the "AddEmbeddedPlot" 
>>>> method to
>>>> be done later once control goes back to the Qt event loop. That means
>>>> that the exception would not be thrown until after you're out of that
>>>> try/catch block. Try using Methods() instead of DelayedMethods() in 
>>>> this
>>>> case.
>>>>
>>>> HTH,
>>>> Brad
>>>>
>>>> On Mon, Feb 22, 2016 at 3:17 PM, sveta <sveta at txcorp.com
>>>> <mailto:sveta at txcorp.com>> wrote:
>>>>
>>>>     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