lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Unfortunatelly in 5.0 there's no luai_* functions.
> I found this code in lvm.c:
> 
>       case OP_DIV: {
>         TObject *rb = RKB(i);
>         TObject *rc = RKC(i);
>         if (ttisnumber(rb) && ttisnumber(rc)) {
>           setnvalue(ra, nvalue(rb) / nvalue(rc));
>         }
>         else
>           Arith(L, ra, rb, rc, TM_DIV);
>         break;
> 
> Ok, I can check for 0, but how can I generate error to Lua?
> I'd like the script to end but the interpreter to continue working.

Try something like this:

      luaG_runerror(L, "division by zero");

(Or you can have a look at luaG_typeerror [in ldebug.c] if you want
more information in the error message.)

-- Roberto