1. Christopher Craft
  2. PowerBuilder
  3. Thursday, 20 February 2020

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

Who is viewing this page
John Fauss Accepted Answer Pending Moderation
0
Votes
Undo

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
Your suggestion of using FindClassDefinition works perfectly for me!
  1. Christopher Craft
  2. Friday, 21 February 2020
Hi Chris ... Note that the FindClassDefinition & related commands will *not* work in PowerServer WEB, IWA or MOBILE deployed applications. ;-)
  1. Chris Pollach @Appeon
  2. Friday, 21 February 2020
There are no comments made yet.
  1. Thursday, 20 February 2020
  2. PowerBuilder
  3. # 1
Michael Kramer Accepted Answer Pending Moderation
1
Votes
Undo

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
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. Christopher Craft
  2. Thursday, 20 February 2020
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. Michael Kramer
  2. Thursday, 20 February 2020
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. Michael Kramer
  2. Thursday, 20 February 2020
There are no comments made yet.
  1. Thursday, 20 February 2020
  2. PowerBuilder
  3. # 2
Miguel Leeuwe Accepted Answer Pending Moderation
0
Votes
Undo

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.
  1. Thursday, 20 February 2020
  2. PowerBuilder
  3. # 3
Christopher Craft Accepted Answer Pending Moderation
0
Votes
Undo

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
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. Christopher Craft
  2. Thursday, 20 February 2020
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. Miguel Leeuwe
  2. Thursday, 20 February 2020
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. Christopher Craft
  2. Thursday, 20 February 2020
There are no comments made yet.
  1. Thursday, 20 February 2020
  2. PowerBuilder
  3. # 4
Miguel Leeuwe Accepted Answer Pending Moderation
0
Votes
Undo

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.
  1. Thursday, 20 February 2020
  2. PowerBuilder
  3. # 5
  • Page :
  • 1


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