Skip to main content
1-Visitor
September 9, 2015
Solved

How to implement exception handling for ProToolkit API's?

  • September 9, 2015
  • 3 replies
  • 1729 views

How to implement exception handling for ProToolkit API's so as to avoid Creo crashing when we pass invalid input arguments?


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
Best answer by Eike_Hauptmann

There is only a exception handling in OTK, inside of TK Exception Handling AFAIK is not possible.

But you can build up you Application as an asynchronous one and that shouldn't pull down creo if it get crashed.

Inside of a scnchronous application often not the TK Command crashes directly with the wrong input. But you read and write to memory cells that's not allowed and if you explicit cast things thats not checkable from the compiler.

Br,

Eike

3 replies

15-Moonstone
September 16, 2015

There is only a exception handling in OTK, inside of TK Exception Handling AFAIK is not possible.

But you can build up you Application as an asynchronous one and that shouldn't pull down creo if it get crashed.

Inside of a scnchronous application often not the TK Command crashes directly with the wrong input. But you read and write to memory cells that's not allowed and if you explicit cast things thats not checkable from the compiler.

Br,

Eike

1-Visitor
September 16, 2015

Thanks Eike.Appreciate it.

14-Alexandrite
September 17, 2015

While compiling in Visual Studio, I have been wrapping most of the Pro/TOOLKIT functions. For example: 

ProError my_function () {

  __try {

     // some code 

  } __catch (EXCEPTION_EXECUTE_HANDLER) {

     // some more code

  }

  return PRO_TK_NO_ERROR;

}

Its probably not the best thing to do from a "coding best-practice" standpoint... but its saved my Creo sessions from crashing, and helped me debug