lua-users home
lua-l archive

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


On 2/16/06, LEGO <luis.ontanon@gmail.com> wrote:
<snip>
...
lua_error(L,"\xff\x01your error code");
...

int handler(L) {
   const char* err = lua_tostring(L,1);
   if ( *err == '\xff' ) switch (*(err+1)) {
     case '\x01':
     case '\x02':
   }
}

That I have thought about.  There are a couple problems with this.  One is that from the programmer's point of view it doesn't make a lot of sense and is extra work they need to do just to return an error code.  The other is related to the first and is a result of using C libraries that normally return error codes.  These are the codes you're often going to want to return and you're going to have to do some verbose string appending to make it all work versus just returning the variable that already has the error code.

--
// Chris