How to catch the exceptions?


I have written the program:

BRepBuilderAPI_MakeWire mW;
TopoDS_Wire w=mW.Wire();
cout }

and get the result:

*** Abort *** an exception was raised, but no catch was found.
... The exception is:0x4285703b : StdFail_NotDone: BRep_API: command not done

(I have seen some simular topics in this forum, there were stories about different exceptions of OCC, but there was no answer.)

so the questions are:
why was not it catched?
how to chatch it?

Rob Bachrach's picture

The NotDone exception is thrown when you try to retrieve the result of an operation that did not complete successfully. In your case, you are trying to retrieve the wire from a BRepBuilderAPI_MakeWire, but there were no edges added, and therefore no operation performed.
If you add an edge to the wire, you should no longer receive the exception.

peter's picture

yes, I understand that. But it is not the problem. Problem is:
how to catch an exception?

that wire without edges in try section I put just to make OCC to throw an exception.

As I understand, catch(...) must catch all the exceptions from try section, and this programs should give \"catch it!!!\' output and continue without stopping.

Rob Bachrach's picture

You might want to check your compile flags. For some operations, CASCADE does not really throw a proper exception and performs as you describe. You must compile without the -DNO_CXX_EXCEPTION flag. If you have that flag set, CASCADE will abort instead of throwing the exception. This took us several days to find.

P G's picture

is this flag setting required for specific OS ... applicable to both windows and unix ??

- PG

Forum supervisor's picture

Hello Peter,

Read the Foundation Classes User's Guide, chapter 2.3.
You will learn there that Open CASCADE Technology brings a (an extensible) hierarchy of exceptions. The root class is Standard_Failure.
Therefore to catch them you have to write:

try {
//your code here
catch () {
//handles particular case
catch (Standard_Failure) {
//handles a general case

where can be either existing exception (see for example in Standard.cdl or Geom.cdl, etc) our your new one.
You will also read that the try and catch operators themselves are redefined.

Best regards,
Forum supervisor

bikithalee's picture

Check this one, this will help you to...catch exception