Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#13019) Meta-Ticket: Improved scripting
Home

[Freeciv-Dev] (PR#13019) Meta-Ticket: Improved scripting

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13019) Meta-Ticket: Improved scripting
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Mon, 9 May 2005 18:48:10 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13019 >

Add even better error reporting for when a callback fails.


? .tutorial.sav.swp
Index: server/scripting/script.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/script.c,v
retrieving revision 1.3
diff -u -u -r1.3 script.c
--- server/scripting/script.c   10 May 2005 01:38:03 -0000      1.3
+++ server/scripting/script.c   10 May 2005 01:47:18 -0000
@@ -138,7 +138,22 @@
 
   /* Call the function with nargs arguments, return 1 results */
   if (lua_pcall(state, nargs, 1, 0) != 0) {
-    freelog(LOG_ERROR, "Error in script function \"%s\"", callback_name);
+    freelog(LOG_ERROR, "Error in script function \"%s\":", callback_name);
+
+    nres = lua_gettop(state);
+
+    /* Output error message. */
+    if (nres == 1) {
+      if (lua_isstring(state, -1)) {
+       const char *msg;
+
+       msg = lua_tostring(state, -1);
+
+       freelog(LOG_ERROR, "%s", msg);
+      }
+    }
+
+    lua_pop(state, nres);
     return FALSE;
   }
 

[Prev in Thread] Current Thread [Next in Thread]