Skip to content

Errors

A compile error stops the compilation of that half of the file. The half is not loaded. On a reload from the RC tool, the previous working version stays active. Each error has a code, a file, a line, a column, and a message, for example unexpected symbol }. All codes are in warnings and errors.

Without a try, a run-time error is reported in the RC chat (server) or the F2 console (client) with the file, the line, and a message, and the script carries on. What happens next depends on the error (OQ-LANG-32):

Code Situation Result without try
R-CALL-ON-NULL A method call on an empty or destroyed object gives empty, the script continues
R-UNKNOWN-FUNCTION No function with that name gives empty, the script continues
R-READONLY-FIELD A write to a read-only field ignored, the script continues
R-REGEX A bad regular expression, or one that runs too long the function gives its failure value
R-SQL, R-HTTP A request could not be made a failed request sets error on the request object and raises nothing
R-LIMIT The script went over a limit the current run is stopped
R-AWAIT An await failed the await gives empty
R-THROW throw outside any try the function ends and gives empty to its caller

Errors never stop the server, other objects, or the client.

try / catch / finally and throw work as described in statements. An error from the engine inside a try can be caught. The catch variable has message, file, line, and type ("script" for throw, "runtime" for engine errors).

function onCreated() {
try {
temp.nothing.run();
} catch (temp.err) {
echo(temp.err.type);
}
// expect: runtime
}

Run this example in the playground

The engine stops a script that runs away, so one bad script cannot freeze the server or a client. Each stop is reported once per object per minute with the object, the script, the line, and the limit.

Limit Server Client
Instructions in one uninterrupted run 5,000,000 2,000,000
Time of one uninterrupted run 50 ms 20 ms
Nested calls 256 256
Array length 1,000,000 1,000,000
String length 16 MiB 16 MiB
Pending scheduled events for one object 10,000 10,000
Suspended functions for one object 1,000 1,000
Loop iterations in one uninterrupted run (nested loops count together) 1,000,000 1,000,000

A function that is stopped does not run its finally blocks. The object stays alive and keeps getting events.

  • Test the result of findnpc, findplayer, and similar lookups for null before using it.
  • Test arrays with != NULL, not with if (list).
  • Expect error on request objects. A failed web or SQL request is not an exception.

Engine version 0.1.0. Built 2026-11-18.