Lua error handling issue

30 views
Skip to first unread message

sillybear

unread,
Jul 11, 2012, 3:26:35 PM7/11/12
to lua-alc...@googlegroups.com
Hi Members,

A quick question, Hope someone can help me out.

By now when lua script failed by whatever reason during doString, it only prints out the error messages to FB console when debugging in FB. 

For example, 
Lua error: luaDoString:44: luaDoString:24: attempt to index local 'field' (a nil value) stack traceback: [C]: in function 'assert' luaDoString:44: in main chunk

Is there a way that we can hook on those error messages and report it back to actionscript cloud?  

Thanks

Alexander Gladysh

unread,
Jul 12, 2012, 2:01:38 AM7/12/12
to lua-alc...@googlegroups.com, lua-alc...@googlegroups.com
Hi,

Have you looked at pcall/xpcall Lua functions?

HTH,
Alexander. 

11.07.2012, в 22:26, sillybear <jxy...@yahoo.ca> написал(а):

yi liu

unread,
Jul 12, 2012, 9:51:10 AM7/12/12
to lua-alc...@googlegroups.com, "lua-alchemy-dev@googlegroups.com"
Hi Alexander,

Thanks for your reply. 

I thought the pcall/xpcall is pure Lua functions, and wont fit my requirement in this case. 

The method  I am looking for here is a way that we can have a chance get error message back from luaAlchemy when we call luaAlchemy doString function.

Looks like the luaAlchemy has this capability already, as error message shows "luaDoString:44: luaDoString:24: attempt to index local 'field' (a nil value)".

It should be luaAlchemy's print out instead of lua, if my understanding is wrong, please correct me.

Kind Regards,



From: Alexander Gladysh <agla...@gmail.com>
To: "lua-alc...@googlegroups.com" <lua-alc...@googlegroups.com>
Cc: "lua-alc...@googlegroups.com" <lua-alc...@googlegroups.com>
Sent: Thursday, July 12, 2012 2:01:38 AM
Subject: Re: Lua error handling issue

yi liu

unread,
Jul 12, 2012, 11:12:32 AM7/12/12
to lua-alc...@googlegroups.com
Please ignore my question, I found the solution. DoString returns an array which includes the error message.

Thanks


From: yi liu <jxy...@yahoo.ca>
Sent: Thursday, July 12, 2012 9:51:10 AM

yi liu

unread,
Jul 12, 2012, 12:30:21 PM7/12/12
to lua-alc...@googlegroups.com
Sorry, me again.

Is there a way luaalchemy can format the error message for a better human understanding? All I have right now is something like following
luaDoString:44: luaDoString:24: attempt to index local 'field' (a nil value)
I really do not know what are 44 and 24 number meaning.

We have similar lua libray in other platforms like Java/C#, both of them returns something like following:

Lua failed: at line 10: field.value NullPointerException.

Thanks,

 
Sent: Thursday, July 12, 2012 11:12:32 AM

Alexander Gladysh

unread,
Jul 12, 2012, 2:53:12 PM7/12/12
to lua-alc...@googlegroups.com, lua-alc...@googlegroups.com
24 and 44 are line numbers. This part of string is formatted by Lua and is pretty much standard. I would like to avoid patching core Lua code just to get customizable error messages. 

If you really want to get your own error message format, you probably can roll your own error handler with xpcall and debug.* functions. 

Note that these functions are on Lua side, they still are perfectly usable from LuaAlchemy. 

Alexander. 

12.07.2012, в 19:30, yi liu <jxy...@yahoo.ca> написал(а):

Reply all
Reply to author
Forward
0 new messages