Inside a C function you can raise an error by calling .

    If an error happens outside any protected environment, Lua calls a panic function (see ) and then calls abort, thus exiting the host application. Your panic function can avoid this exit by never returning (e.g., doing a long jump to your own recovery point outside Lua).

    The panic function runs as if it were a message handler (see ); in particular, the error object is at the top of the stack. However, there is no guarantee about stack space. To push anything on the stack, the panic function must first check the available space (see §4.2).