8. The Aux library

The aux library implements default handlers for compiler and runtime errors and a stack dumping.

8.1. C API

void sqstd_seterrorhandlers(HSQUIRRELVM v)
Parameters:
  • v (HSQUIRRELVM) – the target VM

initialize compiler and runtime error handlers, the handlers use the print function set through(sq_setprintfunc) to output the error.

void sqstd_printcallstack(HSQUIRRELVM v)
Parameters:
  • v (HSQUIRRELVM) – the target VM

prints the call stack and stack contents. the function uses the error printing function set through(sq_setprintfunc) to output the stack dump.

void sqstd_formatcallstackstring(HSQUIRRELVM v)
Parameters:
  • v (HSQUIRRELVM) – the target VM

Prints the call stack and stack contents to the string and pushes resulting string to the stack. Produces the same output as (sqstd_printcallstack) but without using print function.

SQRESULT sqstd_formaterrortracestring(HSQUIRRELVM v, HSQOBJECT trace)
Parameters:
  • v (HSQUIRRELVM) – the target VM

  • trace (HSQOBJECT) – the captured async-fault trace array

Pushes trace as a string, prefixed by an ERROR TRACE header. Returns SQ_ERROR and pushes nothing when trace is not a non-empty trace array.

SQRESULT sqstd_formaterrorcontextstring(HSQUIRRELVM v, HSQOBJECT trace)
Parameters:
  • v (HSQUIRRELVM) – the target VM

  • trace (HSQOBJECT) – the captured async-fault trace array, or null if none

Pushes the stack context for an error report as a string: the live call stack (sqstd_formatcallstackstring) when it has frames (a synchronous fault), otherwise trace (sqstd_formaterrortracestring, for a settled asynchronous fault). Returns SQ_ERROR and pushes nothing when neither is available (trace is null/not a trace array and there is no live call stack). Intended for embedder error handlers.