new implementation for error handling: on error, function _ERRORMESSAGE

is called, which in turn calls _ALERT to write a message to stderr.
This commit is contained in:
Roberto Ierusalimschy
1998-08-21 14:43:44 -03:00
parent 8e226e6a09
commit cc117253c8
8 changed files with 133 additions and 136 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lbuiltin.c,v 1.32 1998/06/29 18:24:06 roberto Exp roberto $
** $Id: lbuiltin.c,v 1.33 1998/07/12 16:16:43 roberto Exp roberto $
** Built-in functions
** See Copyright Notice in lua.h
*/
@@ -192,6 +192,19 @@ static void luaI_print (void) {
}
static void luaB_message (void) {
fputs(luaL_check_string(1), stderr);
}
static void error_message (void) {
char buff[200];
sprintf(buff, "lua error: %.180s\n", luaL_check_string(1));
lua_pushstring(buff);
lua_call("_ALERT");
}
static void luaI_type (void)
{
lua_Object o = luaL_nonnullarg(1);
@@ -568,6 +581,7 @@ static struct luaL_reg int_funcs[] = {
{"copytagmethods", copytagmethods},
{"dostring", internaldostring},
{"error", luaI_error},
{"_ERRORMESSAGE", error_message},
{"foreach", foreach},
{"foreachvar", foreachvar},
{"getglobal", getglobal},
@@ -588,7 +602,8 @@ static struct luaL_reg int_funcs[] = {
{"tonumber", luaB_tonumber},
{"tostring", to_string},
{"tag", luatag},
{"type", luaI_type}
{"type", luaI_type},
{"_ALERT", luaB_message}
};