wait-for: endkey or error

Alexander

New Member
Hi all.
There is an example:

Code:
run p2.
catch e as Progress.Lang.AppError:
    message e:ReturnValue view-as alert-box.
end catch.

procedure p2:
    def var x as int.
    def var c-tmp as char.
    _tr:
    do on error undo, return error 'Error'
        on endkey undo, return error 'Endkey'
        :
        display 'eneky' @ c-tmp. 
        update x.  /* press go or endkey */
        display 'now error' @ c-tmp.
        update x.  /* press  endkey */
    end.
end procedure.

How it works? Why am I getting the error after updating x, and endkey if x wasnt updated?
It's a problem when i try to do something like this:

Code:
/* CLASS cancelerror INHERITS Progress.Lang.AppError: */

do trans on error undo, leave:
  run p2.
  catch ce as cancelerror:
  end catch.
  catch e as Progress.Lang.AppError:
    message e:ReturnValue view-as alert-box title 'ERROR!'.
  end catch.
end.

procedure p2:
do
    on enkey undo, return error new cancelerror(): /* Error to undo external transaction, but dont show any message to user */
   on error undo, return error: /* */
   update x.
   update y.
    /* do some stuff ... */
   catch e as Progress.Lang.Error:
        return error e.   /* Error that i want to user see /
    end catch.
end.
end procedure.

Thanks.
 
Last edited by a moderator:

Cringer

ProgressTalk.com Moderator
Staff member
Hi Alexander, please could you describe what you are trying to do and the errors you are getting. Code snippets are great, but it's a little hard to understand from them what you actually want to achieve.
 

Alexander

New Member
Hi Alexander, please could you describe what you are trying to do and the errors you are getting. Code snippets are great, but it's a little hard to understand from them what you actually want to achieve.
I want to show all errors in message box, except returned by "on endkey undo, return error". And i cant use just "on endkey undo, return" because error required, to stop and undo calling block.
 

Cringer

ProgressTalk.com Moderator
Staff member
You can probably throw a custom error rather than returning 'EndKey'. You can parse the error in the catch and ignore it/rethrow it if it's EndKey.

something like:

on endkey undo, throw new MyEndKeyError
 

Alexander

New Member
You can probably throw a custom error rather than returning 'EndKey'. You can parse the error in the catch and ignore it/rethrow it if it's EndKey.

something like:

on endkey undo, throw new MyEndKeyError
This is exactly what I am trying to do!
But if you use the "update" or "wait-for" more than once in a block, the "wait-for" will throw an error instead of "on endkey undo, throw new MyEndKeyError".
The first code snippet demonstrates this with "return error 'Endkey'" just to be compilable without class definition, but in second is custom "cancelerror()".

Sorry I forgot, progress 10.2B.
 

Cringer

ProgressTalk.com Moderator
Staff member
Procedure P2 in the second example shouldn't be catching anything. Any errors will be passed to p1 and caught there.
You're right you can't have multiple wait-fors in a piece of code. You shouldn't need to.
Still not enitirely clear what you're trying to do but it does sound like you need some error handling help!
 

Alexander

New Member
Procedure P2 in the second example shouldn't be catching anything. Any errors will be passed to p1 and caught there.
You're right you can't have multiple wait-fors in a piece of code. You shouldn't need to.
Still not enitirely clear what you're trying to do but it does sound like you need some error handling help!
If the procedure p2 does not catch and throw the error, then error handling will work in the traditional style, like "on error undo, retutn error" and the error text will not be available in the calling procedure.

I usually use my custom "cancelerror" to cancel the operation/transaction, without any messages, like in files.
 

Attachments

  • cancelerror.cls
    140 bytes · Views: 1
  • errors.p
    1.3 KB · Views: 0

Cringer

ProgressTalk.com Moderator
Staff member
That's why you put this at the top of each piece of code:
Code:
BLOCK-LEVEL ON ERROR UNDO, THROW.
 

Alexander

New Member
That's why you put this at the top of each piece of code:
Code:
BLOCK-LEVEL ON ERROR UNDO, THROW.
Not supported in 10.b

ROUTINE-LEVEL ON ERROR UNDO, THROW - does not work for endkey (ofc, it is not an error).

Code:
ROUTINE-LEVEL ON ERROR UNDO, THROW.

do trans :
    run dlg.
    message 'ok' view-as alert-box.  /* still "ok" even if the user presses "endkey" */
    catch e as Progress.Lang.Error:
        message 'Error' view-as alert-box.
    end catch.
end.

procedure dlg:
    def var x as int.
    update x with view-as dialog-box.
end procedure.
 

Alexander

New Member
Procedure P2 in the second example shouldn't be catching anything. Any errors will be passed to p1 and caught there.
You're right you can't have multiple wait-fors in a piece of code. You shouldn't need to.
Still not enitirely clear what you're trying to do but it does sound like you need some error handling help!
In general, this is the main thing that interested me.
It looks like the only way is to split the blocks.
 

Cringer

ProgressTalk.com Moderator
Staff member
BLOCK-LEVEL was added in 11.2, a long time ago now. Possible it was also added as a Service Pack for 10.2B. You should definitely be on 10.2B08 if you have to stay on 10. But it is now ancient and unsupported.
 
Top