1. Christopher Craft
  2. PowerBuilder
  3. Thursday, 20 February 2020 17:21 PM UTC

I have some code that checks for a custom object and if it doesn't exist I just trap it and continue on. The problem is everytime I run it in the PB IDE it will throw an exception error. If it is running in the EXE then the error is trapped correctly. Does the PB IDE not abide by the TRY-CATCH rules? Following is my code with the error I receive in the IDE:

TRY
    nvoCustomWF = CREATE USING "v_custom_workflow"
CATCH (throwable e1)
    // Catch error if object does not exist so the SystemError event does not fire!
FINALLY
    // If Not Valid then set Shared Variable to NO so we don't try again!
    IF NOT IsValid(nvoCustomWF) THEN
        sbCreateCustomWF = FALSE
    END IF
END TRY

 

 

Chris Craft

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 21:06 PM UTC
  2. PowerBuilder
  3. # Permalink

Greetings, Christopher - 

Instead of attempting the CREATE USING and catching the exception when it fails, I suggest you try using the FindClassDefinition PowerScript function first, and only perform the CREATE USING and related code if the returned ClassDefinition object is not null. This should eliminate the error from being thrown.

Regards, John

Comment
  1. Christopher Craft
  2. Friday, 21 February 2020 14:51 PM UTC
Your suggestion of using FindClassDefinition works perfectly for me!
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 21 February 2020 15:32 PM UTC
Hi Chris ... Note that the FindClassDefinition & related commands will *not* work in PowerServer WEB, IWA or MOBILE deployed applications. ;-)
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 19:06 PM UTC
  2. PowerBuilder
  3. # 1

In the menu "system options" from for example the library toolbar, un-check the Just in Time debugging.

If this problem happens on debugging, don't put any stops on any of the try catch finally statements.

Another thing you could try is to change:

"catch (throwable ... )"

with 

"catch (runtimeerror ...)"

 

See if that helps. (hope it does) :)

Comment
There are no comments made yet.
Christopher Craft Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 19:15 PM UTC
  2. PowerBuilder
  3. # 2

Removing all breakpoints and catching runtimeerror did not help. If I turn off Just in Time Debugging then it will not error. This doesn't seem right does it?

Chris Craft

Comment
  1. Christopher Craft
  2. Thursday, 20 February 2020 19:32 PM UTC
I have it on too but now that we have this new line of code that executes everytime it opens I am always getting the debugger popping up. I am trying to use a Handle(this) call and if in IDE then don't fire but I'm having issues with that too.
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 20 February 2020 20:55 PM UTC
On what are you running handle(this) ? I mean what's in this: the application, a window?

handle(this) on the application won't work if you are running from the IDE.
  1. Helpful
  1. Christopher Craft
  2. Thursday, 20 February 2020 22:53 PM UTC
Correct - if Handle returns 0 then I won't fire the Create but I am running in a thread so this doesn't work. I ended up using the suggestion from Michael and it worked perfectly.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 19:33 PM UTC
  2. PowerBuilder
  3. # 3

My advice is to un-check the "just in time debugging" and temporarily put a messagebox('debug', 'catch runtimeerror') to see if it's working from the ide.

I think I've reported this bug in the past to Sybase, but it's never been fixed. Most probably it was introduced in pb 12.6.

Comment
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Thursday, 20 February 2020 19:51 PM UTC
  2. PowerBuilder
  3. # 4

Hi, inside Debugger there is menu option Debug > Exceptions...

You can define through exception hierarchy which action debugger follows for each exception class:

  • Break into the debugger <== default behavior
  • Continue <== my preferred setting when testing TRY-CATCH blocks
  • Use parent setting <== like "inherit  behavior from ancestor exception class"

MY typical setup is

  • Just-in-Time Debugging = ON
  • "PowerScript Native" exception handling = Continue
  • All other exception classes = Use parent setting

Sometimes I may select Break into the debugger for a custom exception class that certain classes in my app throw at certain times - and I want to know unfiltered EXACTLY> when such exception is thrown.

HTH /Michael

 

Comment
  1. Christopher Craft
  2. Thursday, 20 February 2020 21:34 PM UTC
I did not know that either but...that only works if you run in Debug mode. Unless I did something wrong if you just 'run' the IDE it will still open the debugger on that line.
  1. Helpful
  1. Michael Kramer
  2. Thursday, 20 February 2020 21:50 PM UTC
You're right. Just verified same behavior in 2019 R2.

Combo (A) Just-in-Time debug turned on + (B) Run without debugger + (C) first exception thrown ==> Debugger is invoked. -- AFTERWARDS no interruptions by exceptions marked "continue".

WORKAROUND ==> Start via debugger ==> No interruptions neither for first exception nor afterwards.

  1. Helpful
  1. Michael Kramer
  2. Thursday, 20 February 2020 21:52 PM UTC
I guess the internal mechanics of interruption by debugger on the fly happens before debugger configuration has loaded its "what to do with this particular exception class."
  1. Helpful
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.