1. Roland Smith
  2. PowerBuilder
  3. Monday, 28 June 2021 02:46 AM UTC

Calling PB 2019-R3 object from C++. I'm getting 'Unhandled Exception' in the error object and no exception in the C++ code. Any idea?

The PowerBuilder function:

public function integer of_exception (integer ai_value) throws n_cst_exception;n_cst_exception ex
Integer li_calc

ex = Create n_cst_exception

ex.SetMessage("Something went wrong!")

Throw ex

li_calc = ai_value * ai_value

Return li_calc

end function

The C++ code:

try
{
   // Call the function
   session->InvokeObjectFunction(pbobj, mid, &ci);

   // Was PB exception thrown?
   if (session->HasExceptionThrown())
   {
      // Handle PB exception
      session->ClearException();
      WriteToLogFile(L"PB exception");
   }
}
catch (...)
{
   // Handle C++ exception
   WriteToLogFile(L"C++ exception");
}

 

Accepted Answer
Arnd Schmidt Accepted Answer Pending Moderation
  1. Monday, 28 June 2021 08:29 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi Roland,

not well documented but PushLocalFrame() and PopLocalFrame() should help.

Take a look at that discussion.

https://community.appeon.com/index.php/qna/q-a/use-of-hasexceptionthrown-with-pbni

hth

Arnd

 

Comment
  1. Roland Smith
  2. Monday, 28 June 2021 13:53 PM UTC
Thanks! That worked.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 28 June 2021 13:57 PM UTC
  2. PowerBuilder
  3. # 1

When handling the exception, should I call GetMessage and get the Text property? I haven't used exceptions much before so don't know what the usual design pattern is.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.