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
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.
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.
How to validate the data before passing it to the function? I do not notice there are such functions.
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?
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.
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?
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?
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.
@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?
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.
@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.!
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.
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.
I see. I hope you are not planning to distribute your application to others. That would be very unfortunate.