ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to catch exceptions in RealDWG?

14 REPLIES 14
Reply
Message 1 of 15
alanchen123
807 Views, 14 Replies

How to catch exceptions in RealDWG?

Hi,

 

When calling some functions in RealDWG, such as convertToPolyType(), I will get an exception called “Floating-point stack check”. I use C++ try-catch, but cannot catch the exception:

 

try

{

                …

                If (p3DLine-> convertToPolyType(xxxx) != Acad::eOk)    return   FALSE;

                …

}

Catch(…)

{

                //            cannot catch the “Floating-point stack check” exception.

}

 

Is there a mechanism in RealDWG or ObjectARX that can help to process the exceptions raised when calling functions in these two libraries?

 

Thanks

 

Alan

Tags (2)
14 REPLIES 14
Message 2 of 15
owenwengerd
in reply to: alanchen123

How do you propose to recover from such an exception? I think the only way to "process" it is to prevent it from happening in the first place by validating your data before you call the function.

--
Owen Wengerd
ManuSoft
Message 3 of 15
artc2
in reply to: alanchen123

For ObjectARX there is the acedDisableDefaultARXExceptionHandler() function which turns off the automatic handler that deals with excpetions thrown while code is executing in an arx or dbx module.

Message 4 of 15
alanchen123
in reply to: owenwengerd

How to validate the data before passing it to the function? I do not notice there are such functions.

Message 5 of 15
alanchen123
in reply to: artc2

Can I write my own code that handle the exceptions, instead of just disable all the exceptions?

 

And if the exceptions are disabled, then if an error occurs, then what will happen?

Message 6 of 15
owenwengerd
in reply to: alanchen123

There is no magic function to validate your data. You would need to determine through testing what triggers the exception, then add code to detect that situation and abort your operation before the exception occurs.

 


@alanchen123 wrote:

How to validate the data before passing it to the function? I do not notice there are such functions.




--
Owen Wengerd
ManuSoft
Message 7 of 15
owenwengerd
in reply to: alanchen123

Of course you can write your own code to handle an exception, but it is pointless to do so if you don't know how to recover without leaving corrupted state in memory. Unfortunately you're probably not going to be able to safely recover from this one.

 


@alanchen123 wrote:

Can I write my own code that handle the exceptions, instead of just disable all the exceptions?

 

And if the exceptions are disabled, then if an error occurs, then what will happen?




--
Owen Wengerd
ManuSoft
Message 8 of 15
alanchen123
in reply to: artc2

Does the function acedDisableDefaultARXExceptionHandler() exists in RealDWG as well?

 

I try to read the ObjectARX documents and add

 

#include "aced.h"

 

but compiler said the header file does not exist.

 

I try to search all the source files under RealDWG 2014\Inc folder but cannot find this function.

 

Also I think the way to call this function is

 

acedDisableDefaultARXExceptionHandler(Adesk::kTrue);

 

is that correct?

Message 9 of 15
artc2
in reply to: alanchen123

acedDisableDefaultARXExcedptionHandler() is Acad specific.  RealDWG doesn't have a default exception handler - that would be the responsibility of the host application.

 

I think that Owen's suggestion is your best bet - figure out what's triggering the exception and try to prevent that from happening.

Message 10 of 15
alanchen123
in reply to: artc2


@artc2 wrote:

acedDisableDefaultARXExcedptionHandler() is Acad specific.  RealDWG doesn't have a default exception handler - that would be the responsibility of the host application.

 

I think that Owen's suggestion is your best bet - figure out what's triggering the exception and try to prevent that from happening.


That is a bit contradictory, since it is the responsibility of the host application, why my try-catch codes cannot catch the exceptions?

Message 11 of 15
owenwengerd
in reply to: alanchen123

You haven't provided complete information about the original exception. Is it a C or C++ exception? Have you enabled C++ exception handling in your compiler settings? If it is a C exception, you may need to implement an SEH (Structured Exception Handler) to handle it. However as stated before, this is all academic if you can't actually safely recover from the exception.

--
Owen Wengerd
ManuSoft
Message 12 of 15
alanchen123
in reply to: owenwengerd


@owenwengerd wrote:

You haven't provided complete information about the original exception. Is it a C or C++ exception? Have you enabled C++ exception handling in your compiler settings? If it is a C exception, you may need to implement an SEH (Structured Exception Handler) to handle it. However as stated before, this is all academic if you can't actually safely recover from the exception.


The original exception is occurs when I invoke p3DLine-> convertToPolyType(xxxx), as follows:

 

try

{

                …

                If (p3DLine-> convertToPolyType(xxxx) != Acad::eOk)    return   FALSE;

                …

}

Catch(…)

{

                //            cannot catch the “Floating-point stack check” exception.

}

 

In Visual C++ 2010 Debug version, when trace to the codeline:

 

If (p3DLine-> convertToPolyType(xxxx) != Acad::eOk)    return   FALSE;

 

I will see endless exception report in the output window, like this:

 

First-chance exception at 0x0076de70 in GSFR.exe: 0xC0000092: Floating-point stack check.

 

If I enable the "Exceptions -> Win32 Exceptions -> c0000092: Floating-point stack check" option under "Debug" menu, then Visual C++ will stop at the first exception. But my try-catch code still cannot catch it.

 

Also I need to catch the exception under release version as well, so cannot rely on the exception settings for "Debug version" only.

 

Thank you very much for your helps.!

Message 13 of 15
alanchen123
in reply to: owenwengerd

Moreover, the vertexes of the polylines are inputted by user randomly so it is very difficult to check or validate the vertex values before calling

 

 

p3DLine-> convertToPolyType()

 

Therefore, I want to catch the exception raised from this function so that to prompt the user about the invalid input of the vertex values.

Message 14 of 15
alanchen123
in reply to: alanchen123

It seems that SEH __try and __except can catch the exceptions, but cause a lot of compiler warnings and errors until I use a compiler option to disable them. I am try to find solution for it.

Message 15 of 15
owenwengerd
in reply to: alanchen123

I see. I hope you are not planning to distribute your application to others. That would be very unfortunate.

--
Owen Wengerd
ManuSoft

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost