• Traps as exceptions

    From =?UTF-8?Q?Jens_Lidestr=C3=B6m?=@21:1/5 to All on Fri May 13 00:21:10 2022
    Hello, mumpstereers

    The trap mechanism in Mumps has similarities with the exception mechanism in many other language.

    Most examples I have seem of trap usage is for catching unintentional errors.

    Is there also a way intentionally trigger an error, which can be caught by a trap, in a way that is similar to throwing an exception?

    I am working with GT.M V7.0.

    I’m learning about traps from here: http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/ch13s06.html

    This question is cross-posted on Stack Overflow: https://stackoverflow.com/questions/72215952/traps-as-exceptions

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From ed de moel@21:1/5 to All on Fri May 13 04:55:36 2022
    See also: http://71.174.62.16/Demo/AnnoStd?Frame=Main&Page=a106012&Edition=1995 As an example, you could code:
    Set a=1 Set $Ecode=",U123," Set b=2
    Setting the value of $ECode triggers an error, and the Set b=2 would never be reached.

    Hope this helps,
    Ed

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From K.S. Bhaskar@21:1/5 to [email protected] on Fri May 13 04:22:50 2022
    On Friday, May 13, 2022 at 3:21:11 AM UTC-4, [email protected] wrote:
    Hello, mumpstereers

    The trap mechanism in Mumps has similarities with the exception mechanism in many other language.

    Most examples I have seem of trap usage is for catching unintentional errors.

    Is there also a way intentionally trigger an error, which can be caught by a trap, in a way that is similar to throwing an exception?

    I am working with GT.M V7.0.

    I’m learning about traps from here: http://tinco.pair.com/bhaskar/gtm/doc/books/pg/UNIX_manual/ch13s06.html

    This question is cross-posted on Stack Overflow: https://stackoverflow.com/questions/72215952/traps-as-exceptions

    Jens, does ZMESSAGE (https://docs.yottadb.com/ProgrammersGuide/commands.html#zmessage) help?

    Regards
    – Bhaskar

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Jens_Lidestr=C3=B6m?=@21:1/5 to All on Fri May 13 05:58:08 2022
    Thanks Ed and Bhaskar!

    ZMESSAGE and $Ecode are exactly the mechanisms I was looking for.

    I don't understand how I could have missed them in the manual. I will investigate them.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)