Traps as exceptions

40 views
Skip to first unread message

Jens Lideström

unread,
May 13, 2022, 3:21:11 AMMay 13
to
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

K.S. Bhaskar

unread,
May 13, 2022, 7:22:51 AMMay 13
to
Jens, does ZMESSAGE (https://docs.yottadb.com/ProgrammersGuide/commands.html#zmessage) help?

Regards
– Bhaskar

ed de moel

unread,
May 13, 2022, 7:55:37 AMMay 13
to
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

Jens Lideström

unread,
May 13, 2022, 8:58:09 AMMay 13
to
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.
Reply all
Reply to author
Forward
0 new messages