Traps as exceptions

79 views Asked by At

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

Most examples I have seen 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

1

There are 1 answers

2
Jens On BEST ANSWER

You can do this by setting the $ECODE variable.

See also https://docs.yottadb.com/ProgrammersGuide/errproc.html#ecode.

This is YottaDB but I think it will work for GT.M too.

SET $ECODE=",U13-User defined error trap,"

A simple thing that should work too: S X=1/0