From 208ad62d3cb184688f10198ce42c35cbd3489d90 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 17 Dec 2014 14:43:50 +0000 Subject: elua: error reporting in the library --- src/lib/elua/elua.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/lib/elua/elua.c') diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c index f4411ae1e9..2f88e7be02 100644 --- a/src/lib/elua/elua.c +++ b/src/lib/elua/elua.c @@ -62,6 +62,24 @@ elua_shutdown(void) return _elua_init_counter; } +static void +_elua_errmsg(const char *pname, const char *msg) +{ + ERR("%s%s%s", pname ? pname : "", pname ? ": " : "", msg); +} + +EAPI int +elua_report_error(lua_State *L, const char *pname, int status) +{ + if (status && !lua_isnil(L, -1)) + { + const char *msg = lua_tostring(L, -1); + _elua_errmsg(pname, msg ? msg : "(non-string error)"); + lua_pop(L, 1); + } + return status; +} + static int _elua_gettext_bind_textdomain(lua_State *L) { -- cgit v1.2.1