ApasScript.

Errors

assert

Stops the script unless the condition holds: assert(cond) shows Error: assertion failed: cond, assert(cond, "message") shows the message. A failing assert travels up through every enclosing block, loop and function to the outermost block, which shows the line and ends; the rest of that block does not run. A passing assert shows nothing. In a question's <params>, assert(cond) is the same as require(cond): a failing draw is redrawn (one argument only there).

error

Stops the script with your own message, shown as one Error: message line at that statement. Like a failing assert it travels up through every enclosing block, loop and function; inside attempt(...) it is caught instead and becomes the record's message.

attempt

Calls a function and catches whatever goes wrong: attempt(f, args...) gives the record {ok, value, message}. On success ok is true and value is the function's answer; on any error (an assert, an error(...), a division by zero, an undefined name) ok is false, value is empty text and message is the error's text, and nothing is printed. f is a function written with fn, by name or in place as fn(x) ....