Quirrel4.41.0

error

Global, available without an import
error(...)

Writes its arguments to the error stream.

examples/globals/error-basic.nut
error("squad wiped:", "no ammo left")   // goes to stderr, not stdout
println("\nstdout: still running")       // error() does not stop the script; adds no newline of its own
Output:
squad wiped: no ammo left
stdout: still running

Parameters

...anyvalues to write; each is converted the same way print converts its arguments repeats

Return value

null.

Notes

Goes to the error stream (stderr on the command-line host), a stream print and println never touch. Several arguments are joined with a single space, same as print, and error adds no trailing newline of its own, same as print too - call errorln for that.

The example on this page prints on both streams. The site's exec-test runner captures them merged into one file, in the order each write happened (the host disables output buffering to keep that order stable), so a mix of print-family and error-family calls is safe to commit here.

Example

examples/globals/error.nut
println("stdout: starting")
error("stderr:", "something went wrong")  // several arguments join with one space, like print
errorln("")                                // error() itself adds no trailing newline
println("stdout: continuing")
Output:
stdout: starting
stderr: something went wrong
stdout: continuing

See also

errorlnWrites its arguments to the error stream, followed by a newline.
printWrites its arguments to the output stream.
globalsmodule index