6. Conditions and errors


6. Conditions and errors

This chapter covers how both machines raise, trap and report conditions: the condition kinds, SIGNAL ON / CALL ON traps and their inheritance, the delayed handling of CALL ON, RAISE, CONDITION() and the condition object, how a condition travels across routines and methods, the report of an untrapped error (with its traceback), and where the error texts come from. It assumes the activation model of the machine (frames, pushActivation / popActivation, clause boundaries); activities, HALT sent by Message~halt and errors in other activities are in concurrency.

Both hosts implement the same design with the same names: the ooRexx host in ../RVM.Machine.cls (labels RunTraps, CallTrap, Failed, FailedUnwind; routine ErrorReport) and ../RVM.BaseContext.cls (trap table, classes RVM.Trap, RVM.Throw, RVM.ConditionInfo); the JavaScript host in ../js/machine.mjs (runTraps, callTrap, failed, unwind, raise, report), ../js/context.mjs and ../js/errors.mjs. Unless stated, what follows holds for both; observable behaviour matches native ooRexx 5, which is the oracle.

Condition kinds

Condition Raised by SIGNAL ON CALL ON Untrapped ::OPTIONS c SYNTAX
ERROR a command with RC ≠ 0 (and an untrapped FAILURE) yes yes nothing 98.970
FAILURE a command that fails to run (e.g. not found) yes yes raised again as ERROR 98.971
HALT Message~halt, RAISE HALT yes yes error 4.1 —
NOTREADY stream I/O (BIFs and Stream methods) yes yes nothing (the operation returns its default) 98.974 (not from a STREAM command)
NOVALUE reading an unset variable (simple, compound, PARSE VAR; not a whole stem nor a stem with a default) yes no (25.1 at translate) value is the name 98.986
LOSTDIGITS an arithmetic operand with more digits than DIGITS yes no nothing (operand truncated) 98.972
NOSTRING an object with no string value converted to a string (requestString) yes no nothing 98.973
NOMETHOD a message with no method and no UNKNOWN yes no 97.1 (97.2 private, 97.3 package) —
SYNTAX every Rexx error, RAISE SYNTAX yes no error report, program ends —
USER name RAISE USER name only yes yes nothing —
ANY (trap only) catches all all but SYNTAX NOVALUE LOSTDIGITS NOMETHOD NOSTRING — —

Where each is raised:

  • ERROR / FAILURE: CommandCondition (both hosts, after IssueCommand), with DESCRIPTION = the command, RC and RESULT = the return code. An untrapped FAILURE becomes an ERROR condition (98.970 if ERROR is SYNTAX). Commands are in I/O and commands.
  • NOTREADY: raiseNotready in ../RVM.Stream.cls and ../js/streams.mjs. DESCRIPTION is the stream name, RESULT the operation's result, PROGRAM "REXX" and no POSITION (it is raised in a method of the REXX package); ADDITIONAL is the Stream object (for a stream of the functions, which has none, RVM.World~streamObject makes it, Stream~new(name) as native resolveStream does, the first time it is asked for, and keeps it: RVM.Stream~rexxObject). Its traceback starts with the lines native ooRexx shows for the Stream methods involved (nativeStack, see Traceback), and its STACKFRAMES with their frames (nativeFrames): the Method, the Stream object (or the monitor) as receiver, the arguments that method got (RVM.Stream~opArgs, set by the function: those of the call, omitted ones too; LINES gets NORMAL when the option is omitted; COMMAND's inner method, its options uppercased).
  • NOVALUE: NoValue / noValue. DESCRIPTION is the derived name (B.5 after a. = b.).
  • LOSTDIGITS, NOSTRING: lostDigits and noString in the context; they do nothing at all when the activation has no trap. NOSTRING's ADDITIONAL is the object, DESCRIPTION the string its STRING gave.
  • NOMETHOD: the send path (SendLoop / doSend). DESCRIPTION is the message name, ADDITIONAL the receiver. A SIGNAL ON trap does not return; otherwise the send fails with 97.x.
  • HALT: RVM.Context~halt marks the activation (haltPending) and forces a clause boundary; RunTraps raises it once the CALL ON traps already pending have run (see concurrency). Ctrl-C (SIGINT, SIGTERM, SIGHUP) is a HALT for every activity, as native (07). The machine's own 4.1 (an untrapped HALT) is raised with the description RVM.Halt, so that it is not taken for the host's HALT falling in the machine's code.

Data structures

ooRexx host (RVM.BaseContext.cls) JS (context.mjs) Role
RVM.Trap (condition, isSignal, target, state ON/DELAY) Trap one SIGNAL ON / CALL ON
RVM.ConditionInfo ConditionInfo a raised condition: what CONDITION() reports
RVM.Throw (info, trap, level, reraise) Throw a condition travelling down the stack while activations unwind

ConditionInfo fields: condition, description, rc, code (SYNTAX: major.minor), additional (SYNTAX: the message inserts, an array of the machine; otherwise any object), instruction (SIGNAL/CALL once trapped), result (RAISE's RETURN/EXIT value), objResult (the condition object's RESULT), position, program, propagated ("0"/"1"), message (SYNTAX secondary message when known), stack (the traceback lines, taken when raised), traceback (SYNTAX: the report lines when a trap took it, for a later RAISE PROPAGATE), nativeStack (NOTREADY prefix lines), and the cached objects additionalObj, stackObj, framesObj.

Per activation, the context holds (see the comment block above ::Attribute traps in RVM.BaseContext.cls):

  • traps: condition key → trap. Keys are the condition name, "USER NAME" for user conditions, and "ANY".
  • condition: the ConditionInfo currently reported by CONDITION().
  • callTraps / callTrapsPending: CALL ON traps fired in the current clause.
  • thrown: the Throw in flight; raising: a pending RAISE ... RETURN.
  • errorLines / errorHeader: the lines and header of an error report being collected while unwinding.

Setting traps and inheritance

SIGNAL ON c [NAME l] and CALL ON c [NAME l] compile to TRAPON key S|C target (the default target is the condition name; for USER x, x); SIGNAL OFF / CALL OFF to TRAPOFF key (R-code). CALL ON SYNTAX and the other conditions CALL ON cannot trap are translate-time errors (25.1) from the parser.

  • One trap per key: SIGNAL ON ERROR and CALL ON ERROR replace each other.
  • Lookup (TrapIn): the specific key first; ANY only if the specific one is absent, and a CALL ON ANY is ignored for SYNTAX, NOVALUE, LOSTDIGITS, NOMETHOD and NOSTRING.
  • A called activation (internal routine, external routine, method) starts with the caller's table, shared until it changes it (ownTraps: copy on first write), and with the caller's current condition; nothing is pending for it. popActivation restores the caller's table, condition and pending CALL ON traps. So with SIGNAL ON SYNTAX in the main program, an error in an internal routine is caught by the routine's inherited copy of the trap, in the routine's activation.
  • ::OPTIONS ... SYNTAX conditions (syntaxConds, saved per activation): setting or removing a trap for one of them (or ANY) turns the SYNTAX conversion off in that activation (dropSyntaxCond, as ooRexx's trapOn/trapOff; for LOSTDIGITS, NOSTRING and NOVALUE only a SIGNAL trap does it). RAISE is never converted.

Raising a condition: immediate and delayed

Every non-SYNTAX condition goes through raiseCondition(info) of the context:

  1. locate(info) records where: the traceback (stackLines, see below), the program and line of the current clause (none inside a compiled prelude method: it takes the place where it lands; a NOTREADY gets program REXX).
  2. trapFor(condition); none → returns false (the raiser then applies the untrapped behaviour of the table above).
  3. Trap in DELAY (its CALL ON handler is running) → returns true, nothing happens.
  4. SIGNAL ON → immediate: thrown = Throw(info, trap, callDepth) and a host-level exception is thrown (ooRexx host: Raise Syntax 98.900 with description RVM.Trap; JS: RexxError with kind = "trap"). Whatever the machine was doing is abandoned; see Unwinding.
  5. CALL ON → delayed: queueCallTrap(trap, info); returns true.

CALL ON: at the clause boundary

Queued traps run when the clause ends. The machine checks callTrapsPending at CLAUSE, LABEL and BOUND instructions and before SIGNAL, RETURN and EXIT take effect; it then jumps to RunTraps with again = the address of that instruction, which runs again after the handlers. (BOUND is emitted where a clause ends without a following CLAUSE, e.g. before the jump out of THEN/ELSE branches.) A trap fired inside a function call therefore waits until the whole clause has finished.

CallTrap for each queued pair, in order:

  • instruction = "CALL"; RC is set if the condition has one; the trap goes to DELAY;
  • a label target: a new frame of kind TRAP returning to again; SIGL = the line of the current clause; the handler's only argument is the condition object (conditionObject(info), a fresh Directory); the handler's CONDITION() is this condition;
  • a non-label target (TrapRoutine, as ooRexx's RexxInstructionCallOn::trap): a built-in function, or else an external routine, called with the condition object;
  • on return (DoReturn, frame kind TRAP, or TrapDone): the trap goes back to ON, the result is ignored, the next queued handler runs, then again.

EXIT runs the pending traps first when it is in the main program; inside a routine they are lost, and the unwinding to the main program (ExitUnwind) discards those of each level left, running only the main program's (as native). A pending flow change typed at an interactive pause waits in pendingFlow while the traps run.

HALT is checked in RunTraps when no CALL ON traps remain: if trapped by CALL ON it is queued and runs immediately at that same boundary; untrapped it is error 4.1.

SIGNAL ON: landing

When the unwinding reaches the activation that owns the chosen trap (end of FailedUnwind / unwind): the pauses of the levels left end; a SYNTAX keeps its report lines in info.traceback; errorLines, native lines and active INTERPRETs are cleared; instruction = "SIGNAL"; the trap is turned off (trapOff); the condition becomes current; RC (SYNTAX: the major number; ERROR/FAILURE: the command's RC) and SIGL (the line of the clause where it lands, i.e. the clause in error or the caller's CALL) are set; trace indentation resets; control goes to the label. A missing label is 16.1 when the trap fires, not when it is set.

SYNTAX errors

A Rexx error is raised by the machine as a host exception: in the ooRexx host a real ooRexx SYNTAX condition (Raise Syntax code Additional(...)), caught by the Signal On Syntax Name Failed that execute keeps active; in JS a RexxError (code, inserts, optional own message), caught in the run loop and passed to failed. Compile-time decisions that ooRexx reports at run time compile to ERR code insert (e.g. 17.1, 98.993, 99.913 as a guard) and ERRJ (28.x, after setting the trace level), and unsupported constructs to ERR 93.900 "RVM: ... not supported yet".

Unwinding (Failed)

Failed / failed distinguishes:

  • a trap or RAISE in flight (thrown set; descriptions RVM.Trap, RVM.Raise; JS kind "trap"/"raise");
  • a plain error: a new ConditionInfo("SYNTAX") with code, additional, message taken from the host condition (BifCodeOf, ErrorAdditional, BifMessageOf; see Error texts), the lines of the natives running first (NativeLines), stack = stackLines(...), position of a failing INTERPRET if any, then locate; Throw(info, null, frames.items).

Then FailedUnwind loops over activations, innermost first:

  • deeper than throw.level → pop the frame (collecting its report lines when the throw is a RAISE that skips levels);
  • at throw.level: look for a SYNTAX trap (trapFor("SYNTAX"), state ON), unless the throw already carries a SIGNAL trap. A forwarded activation (FORWARD without CONTINUE, level.forwarded) does not look: its errors go to the caller, as native (and so do its other conditions: 08);
  • untrapped and not at level 0: keep this activation's lines (KeepErrorLines), propagated = "1", pop, append the caller's lines (KeepNativeLines: a compiled prelude method that leads to user code is one Compiled method line; the natives that led to the callee, e.g. NEW→INIT, are listed below it), decrement throw.level, repeat;
  • untrapped at level 0: the activity ends with the error (failedInfo, errorLines, errorHeader); the report is printed by EndActivity (or by the launcher for a direct run). Errors in an UNINIT are not reported; a message whose activity failed is notified first (concurrency).

Special cases: an error in a line typed at an interactive pause is shown as +++ Interactive trace. Error n: text (DebugError) and the pause goes on; a Message~send that fails notifies its parties before the error continues; Message~result re-raises the message's error (Throw.reraise: the original lines are kept, the "running" line names the RESULT clause); an error (or a RAISE) that ended a nested machine run by a native (sendSync, runSync) goes on in the machine below with that machine's condition and lines: SyncFailed leaves them (with its failedInfo and errorLines) in RVM.ConditionInfo~syncFailure (JS: syncErr on the exception), and Failed takes them instead of making a new condition. The report lines come first (a line 0 of a native at the bottom of that machine, REQUEST for MAKEARRAY, gets the line of the clause here), then the natives' and this activation's; the stack goes on with this machine's unless it already does (outerContext); PROPAGATED is 1; a condition raised again out of it (RAISE PROPAGATE) is located here. The check of the report (RVM_TBCHECK) is done in the machine below. In the ooRexx host the condition must match the host's (code and description); a native that swallows the error (a TraceObject whose send fails) clears it.

Other host-level failures: in JS a RangeError (a string or array too big for V8) becomes error 5 ("System resources exhausted."), as ooRexx reports memory exhaustion; an exception that is not a RexxError is an internal bug and escapes. Recursion deeper than maxDepth / MAX_DEPTH (10,000 activations) is 11.1.

CONDITION() and the condition object

CONDITION(option) (BIF.CONDITION in ../RVM.BIFs.cls, CONDITION in ../js/bifs.mjs) reads the activation's current condition (trapped here or inherited from the caller):

Option Result
I (default) SIGNAL or CALL
C condition name (USER FOO for user conditions)
D description ("" if none; a real SYNTAX error has "")
E SYNTAX minor code (12 for 40.12)
S current state of the trap for exactly this name: ON, OFF, DELAY
A ADDITIONAL (.nil if none)
O the condition object (.nil without a condition)
R forgets the condition, returns ""

Without a condition every string option returns "".

The condition object (RVM.Context~conditionObject, JS World.conditionObject in ../js/objects.mjs) is a new Directory on each call; its items are shared:

Index Present Value
CONDITION, DESCRIPTION, PROPAGATED, PROGRAM always PROGRAM is "" if unknown
INSTRUCTION once trapped SIGNAL / CALL
POSITION when raised at a line line of the raising clause (inside INTERPRET: the INTERPRET's line)
RC SYNTAX, ERROR, FAILURE, or RAISE with RC
ADDITIONAL SYNTAX always (possibly empty Array), others if given the same object on every call (additionalObj)
RESULT ERROR/FAILURE (the RC), NOTREADY (operation result), RAISE RETURN/EXIT value
TRACEBACK always List of report lines, built once (stackObj)
STACKFRAMES always List of StackFrame objects, built once (framesObj); see reflection
PACKAGE when a frame has one the package of the innermost frame with one; the REXX package when PROGRAM is REXX (a NOTREADY, an argument error of a REXXUTIL routine)
CODE, ERRORTEXT, MESSAGE SYNTAX CODE is "4.0" style if no minor; MESSAGE is .nil for minor 0, else the secondary text with inserts and a final period; unfilled inserts stay as &n

Example (both hosts and native print the same):

signal on syntax
call r
exit
r: raise syntax 40.12 array('ABS', 1, 'x') description 'd'
syntax:
  c = condition('O')   -- CODE 40.12, RC 40, POSITION 4, PROPAGATED 0,
                       -- MESSAGE 'ABS argument 1 must be a whole number; found "x".'
  do l over c~traceback; say l; end
  --      4 *-*   raise syntax 40.12 array('ABS', 1, 'x') description 'd'
  --      2 *-* call r

PROPAGATED becomes 1 when the condition leaves an activation that does not trap it, or on RAISE PROPAGATE.

RAISE

RAISE compiles to RAISE K w i with the operands on the stack (R-code): code/RC, DESCRIPTION, ADDITIONAL, the ARRAY items (i = −1 when absent), and the RETURN/EXIT value; K = 0 is PROPAGATE, w is RETURN or EXIT. Operands keep their object values. The RAISE case in execute / Machine.raise:

  • RAISE PROPAGATE takes the current condition (none: 98.918), marks it propagated, updates RESULT; a SYNTAX one is re-located where it lands (program/position/message cleared and recomputed).

  • Otherwise a new ConditionInfo, its traceback taken now, located at the RAISE clause.

  • SYNTAX: the code must be n or n.m with whole parts (33.904); RC becomes the major, code the canonical major.minor.

  • ADDITIONAL for SYNTAX goes through ooRexx's requestArray: an Array, a string's lines, or an object's REQUEST('ARRAY'); .nil or multi-dimensional is 98.939. ARRAY(...) items replace it. Number inserts become strings.

  • RETURN vs EXIT (TopLevel): RETURN acts in the current activation; EXIT (the default) first ends the internal routines and CALL ON handlers up to the program, routine or method activation (raiseExit).

  • SYNTAX is thrown as an error with a target level:

    Form Error raised at
    RAISE SYNTAX ... RETURN this activation
    RAISE SYNTAX ... (EXIT) the top-level activation it runs in
    RAISE PROPAGATE RETURN (of a SYNTAX) the caller
    RAISE PROPAGATE (EXIT) the caller of the top-level activation

    No trap on the way sees it; untrapped at its level, its report still has the lines of every activation it went through. A propagated SYNTAX that was trapped keeps the lines it had when trapped (info.traceback), plus those of the levels above; the "running" line then names where it was raised again (errorHeader). RAISE PROPAGATE out of the main program has no caller: the report has no "running" line (Error 98: Execution error.).

  • Other conditions are raised in the caller once the routine returns: context.raising holds it, DoReturn returns the RETURN/EXIT value and calls RaiseInCaller (the condition fires in the caller's CALL clause). RAISE HALT|NOMETHOD ... RETURN that the caller does not trap (callerTraps, as ooRexx's senderActivation->trap) is an error at the RAISE itself: 4.1 / 97.5 (UntrappedRaise).

  • In the main program (or after an EXIT unwinding reaches it) nobody can see the condition: HALT → 4.1, NOMETHOD → 97.5, anything else ends the program silently with exit code = the EXIT value's string.

Propagation across routines and methods

  • Trapped conditions other than SYNTAX are handled only in the current activation (with its inherited trap table): there is no upward search. A NOMETHOD inside a method not trapped there becomes 97.1, which then travels as a SYNTAX.
  • SYNTAX travels activation by activation (FailedUnwind), each one checking its own (possibly inherited) SIGNAL ON SYNTAX / ANY. Internal routines, external routines, routines of other packages, methods and prelude methods are all activations in this sense.
  • A trap handler's own errors are ordinary errors of its activation (a CALL ON handler is an activation of kind TRAP).
  • RAISE ... RETURN delivers to the caller; RAISE PROPAGATE re-raises the current condition one level up.
  • Errors from a STARTed message or another activity: see concurrency.

The error report

An untrapped error prints, on the trace output (each line through traceRaw, i.e. .TRACEOUTPUT, as ooRexx's displayUsingTraceOutput):

     5 *-*   y = x / 0
     1 *-* call sub
Error 42 running /path/e1.rex line 5:  Arithmetic overflow/underflow.
Error 42.3:  Arithmetic overflow; divisor must not be zero.
  • Traceback lines, innermost first: Right(line, 6) "*-*" + the clause as traced, at the trace indentation it had (clauseTraceLine; nested calls indent by two). Lines with line number 0 or empty text are not printed.
  • "running" line: Error M running <program> line N: <ErrorText(M)>, where program and line are those of the first traceback line (an error in an external routine names its file; one inside a prelude method names REXX). With errorHeader = position/program it names where a RAISE PROPAGATE re-raised it; with errorHeader = "" (propagated out of the main program, or a START whose message has no Rexx method) it is Error M: <text>. An error in the arguments of a REXXUTIL routine has no line: Error M running REXX: <text> (errorHeader = (.Nil, REXX); 12).
  • Secondary line: Error M.m: <message> with a final period added; absent for X.0 codes (no secondary message).
  • Exit code: minus the major number (ErrorReport / report return -M); the shell sees 256 - M.

Traceback line kinds, as native:

Line Source
NNN *-* clause a Rexx activation (levelLines / ErrorLines)
*-* Compiled method "NEW" with scope "Array". a native method on the way (nativeLines, RVM.NativeCall, NativeText); no line number
*-* Compiled routine "SYSSLEEP". a library routine
477 *-* Method UNION with scope "Set" in package "REXX" (no source available). a prelude method from CoreClasses.orx (real line numbers, see prelude); the "running" line then says running REXX line 477
*-* Compiled method "<op>" with scope "Stream"., then NNN *-* Method COMMAND with scope "Stream" ... (a STREAM command) or 1457 *-* Method UNKNOWN with scope "Monitor" ... (a standard stream) NOTREADY (nativeStack, built in raiseNotready)
the INTERPRET data clause above the interpret clause an error in INTERPRETed code (interpretLines); a fragment that does not parse adds a COMPILE line (interpretError)

Attribute and constant natives add no line; the RVM's own compiled prelude methods (those written for the RVM, compiled) are hidden and contribute one Compiled method line where they lead to user code.

A program that does not parse is reported by the launcher (ParseError in ../rvm.rex, reportError in ../js/runner.mjs) with the clause the parser stores in the error (CLAUSE, via ParseErrorLine), control characters shown as ?.

Traceback = report. TRACEBACK is computed when the condition is raised by walking the stack without changing it (stackLines, which mirrors the unwinding: current activation plus savedActivations paired with the machine's frames and levels); the report is collected while unwinding (KeepErrorLines, KeepNativeLines, ErrorLines). With the environment variable RVM_TBCHECK set, both hosts compare the two for every untrapped error and print RVM_TBCHECK mismatch in <program> with both versions on stderr (TracebackCheck / tracebackCheck; JS only under Node).

Error texts

Text ooRexx host JS host
Major (ErrorText(n)) the host's ErrorText BIF ERROR_TEXT in rvm-data.mjs
Secondary, from code + inserts the host's ErrorText(code, inserts) (ooRexx r13480, RFE #766) SECONDARY in rvm-data.mjs, secondaryText in ../js/errors.mjs
Secondary of an error raised by the machine the host interpreter's own message (Condition('O')~message) RexxError.text (secondaryText)
BIF errors 40.x of the functions' own checks RVM.BifMessages in RVM.BIFs.cls MESSAGES in ../js/bifcore.mjs

../js/gendata.rex generates rvm-data.mjs from the host's ErrorText: ERROR_TEXT from ErrorText(0..99), and SECONDARY from every code 0.1 to 99.999 that has a text, as a map from major.minor (minor padded to 3 digits) to texts with inserts written <n:> (ERRORTEXT writes them &n) (also BIF signatures and the SysGetMessage table). Both files carry ooRexx message texts and are under the CPL (licensing). Codes are canonicalised as ooRexx shows them (canonicalCode: 16.001 → 16.1, 40.900 stays). Missing inserts show as &n, as native.

An object as an insert shows its string value, as ooRexx's messageSubstitution (stringValue): a MutableBuffer's text, a StackFrame's traceback line, a stem's default, a VariableReference's value, otherwise its name — the OBJECTNAME message's result when Rexx code makes it (RVM.Obj~string, JS traceText, in their "safe" form: see 08). ADDITIONAL keeps the object itself. In the ooRexx host the host substitutes the name it gives the RVM.Obj, so BifMessageOf makes the message again from the strings when one of them differs (MessageWith: the same code raised and trapped); the JS host's secondaryText takes traceText() directly.

BIF errors. The ooRexx host cannot raise codes absent from its rexxmsg.xml (e.g. ANSI 40.9). BifError(code, bif, inserts...) therefore raises major.900 with ADDITIONAL (text, used-inserts[, method-error]) and DESCRIPTION "RVM.Message <code> <text>"; BifCodeOf, BifMessageOf and ErrorAdditional recover the real code, message and inserts wherever a host condition is turned into a Rexx condition. The JS host simply builds a RexxError(code, inserts, ownMessage).

40.x and 93.9xx. Built-in functions report native's errors: those that ooRexx runs as methods of String check their own arguments (40.x) and then give the method's (93.9xx); the stream functions, the Stream methods'; BEEP, FILESPEC and DIRECTORY, a routine's (88.9xx) (11). Where a String method computes by calling the BIF's code, that code passes the method's error alongside (BifMethodError / bifMethodError: third item of ADDITIONAL, JS e.methodError), and the method's error handler (BifFailed in ../RVM.Objects.cls, the catch in ../js/objects.mjs) raises that instead; C2D and X2D turn 40.35 into 93.936 / 93.935.

ERRORTEXT(n) follows ooRexx: whole number 0–99, "" for an unused number, 40.903 out of range.

Host-level mechanics

Both machines use their host's exception mechanism as the single channel for anything that abandons the current instruction, distinguished by a marker:

ooRexx host (description of the SYNTAX condition) JS Meaning
(none) RexxError, kind = "error" a Rexx error
RVM.Trap kind = "trap" a SIGNAL ON trap fired (thrown holds it)
RVM.Raise kind = "raise" RAISE SYNTAX / PROPAGATE / reraise
RVM.Message code text RexxError.ownMessage a BIF error with its own code/message
RVM.NeedString NeedString an object's Rexx STRING must run first (objects)
RVM.StreamThrow (internal to streams.mjs) a stream operation unwinding after NOTREADY
— FINISHED, WAITING, SWITCH program end, activity waits, activity switch (concurrency)

In the ooRexx host any ooRexx SYNTAX condition raised while execute runs, including one caused by a bug in the RVM itself, becomes a Rexx error of the program.

Host differences

The observable behaviour is the same in both hosts for every case probed. Implementation differences: RVM_TBCHECK is checked only under Node in JS; the JS RangeError → error 5 mapping has no ooRexx-host counterpart (the host interpreter runs out of memory instead).

Design notes

  • Errors are host exceptions; the machine never nests. A trap or error abandons the instruction through the host's exception and is handled by a single catch point per machine (Failed / failed), which unwinds the machine's own frames explicitly. This keeps the machine a flat loop over frames (no host recursion per Rexx call) and makes every abandonment, of whatever origin, follow one path. Why the machine never nests is in 05.
  • CALL ON is delayed to the boundary and the boundary instruction re-runs. Native ooRexx runs pending traps in processClauseBoundary; checking a flag only at CLAUSE/LABEL/BOUND and before SIGNAL/RETURN/EXIT costs one test per clause, and re-executing that instruction after the handler avoids saving any partial state.
  • Trap tables are copy-on-write. Most callees never change traps; sharing the caller's table until the first change keeps calls cheap while giving the inheritance native has (RexxActivation.cpp).
  • The condition is located when raised. POSITION, PROGRAM and TRACEBACK are taken at raise time because native does so; the condition object is built lazily on each CONDITION('O'), with TRACEBACK, STACKFRAMES and ADDITIONAL built once so the same objects come back, as native.
  • The report is the traceback. The report is collected while unwinding and the traceback by walking the stack; they are independent computations of the same thing, and RVM_TBCHECK keeps them equal.
  • Prelude methods show native's lines. The prelude is CoreClasses.orx trimmed with line numbers preserved, so errors in those methods show the same Method X with scope Y in package "REXX" lines and line numbers as native; the RVM's own helper methods stay invisible like ooRexx's C++ methods.
  • BIF errors are native's. Native ooRexx raises "method" errors (93.9xx) from many BIFs because it runs them as String methods; the RVM runs them the same way, so its codes, messages and order of checks are native's (17).
  • Codes the host lacks travel in the description. The ooRexx host can only raise codes its own message table knows; carrying the real code and text in the description of a generic major.900 lets the RVM raise any code without patching the host.

Known gaps

  • STACKFRAMES details: see reflection (invocation numbers).