-
Isidro Reina Monsó
- PowerBuilder
- Friday, 7 August 2020 07:11 AM UTC
Hi.
I wrote this simple function in PB for testing:
public function long uof_square (long al_arg) throws exception;exception ee = create exceptione.Text = "test"throw ereturn al_arg * al_argend function
As you can see, it will always throw an exception.
I'm trying to invoke that function from a C++ application using PBNI. My goal is to capture the exception e in my C++ code to access its information. I'm using the code that you can see in the examples in the PBNI Manual:
...
// Call the function
try { session->InvokeObjectFunction(pbobj, mid, &ci); // Was PB exception thrown? if (session->HasExceptionThrown()) { fprintf(stdout, "Exception!!"); // Handle PB exception session->ClearException(); return 1; } } catch (...) { // Handle C++ exception }
...
However, when I do that, in the InvokeObjectFunction() call I get a message telling me that the exception has not been handled. If I capture the exception in my PB code, either with a try-catch or by writing in the systemerror event of the application, I don't get the message, but HasExceptionThrown() returns 0, and the exception isn't available from my C++ code.
Am I doing something wrong?
If not, what's the point of HasExceptionThrown() if the exception will never be able to reach the C++ code?
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.