Natural error code for user-initiated error condition

Product/components used and version/fix level:

Natural all levels

Detailed explanation of the problem:

Does anyone know if there is a Natural error code reserved for user use?
For example, if 1234 was the reserved error code, then

 MOVE '1234' TO *ERROR-NR

would trigger a user-initiated program error condition and then in the program the ON ERROR block would receive control:

ON ERROR
IF ERROR-NR = 1234 / user-initiated
WRITE ‘PROGRAM TERMINATED BY USER’
TERMINATE 16
END-IF

END-ERROR

Thanks,
Steff Gladstone

Error messages / full error message screenshot / log file:

Question related to a free trial, or to a production (customer) instance?

I don’t believe there is one reserved for users, but it is modifiable.

You could choose one that is not being used (via SYSERR).

Then you would do a FETCH of *ERROR-TA (which is also modifiable or defined via NSS).

Try it and let us know.

Eugene (Gene) Miklovich

ADABAS/NATURAL Systems Support and DBA

Cell: 916-202-7047

Normal Hours: 8am-4pm E.T.

Please call or text if assistance needed outside these hours.

Basically there are two types of error codes and especially messages associated with them: NATURAL and USER Error messages

When assigning a value to *ERROR-NR NATURAL will always trigger a SYSTEM error, even if a message with that number is defined for the respective user library in SYSERR.

As there are no defined ranges for “user initiated errors” you will need to make sure you are preferably picking an error code NOT associated with an error (currently) used by NATURAL.

Like Eugene said, you can do this using the SYSERR utility which is there for viewing and manipulating message texts, both NATURAL and USER messages.

Current list of used error numbers from OpenSystems NATURAL for the range starting 1200, for example

There is no number or range reserved for user-initiated messages. In any case, I would strongly recommend not to use just any ‘free’ number. Many which looks free, are reserved for specific tools or on other platforms and can be used at any new version. Best is if you open an Aha request for User-defined system messages. Then we can reserve (and maybe initialize) a range of messages for users.
For now (temporary), you may use the number 2007. This is in a range which we want to release anyway. But if the range of user-defined system messages is finally implemented elsewhere (or nowhere), it can happen that you have to move you message to another number.