pposix: Standardize error messages

Tue, 03 Mar 2009 17:25:20 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Tue, 03 Mar 2009 17:25:20 +0000
changeset 865
2dce34e9182d
parent 864
416c812acde5
child 866
8958fe4b2391

pposix: Standardize error messages

util-src/pposix.c file | annotate | diff | comparison | revisions
--- a/util-src/pposix.c	Tue Mar 03 17:24:56 2009 +0000
+++ b/util-src/pposix.c	Tue Mar 03 17:25:20 2009 +0000
@@ -322,7 +322,7 @@
 	int rid = -1;
 	if(arguments < 1 || arguments > 3) {
 		lua_pushboolean(L, 0);
-		lua_pushstring(L, "Wrong number of arguments");
+		lua_pushstring(L, "incorrect-arguments");
 	}
 	
 	resource = luaL_checkstring(L, 1);
@@ -337,7 +337,7 @@
 		if (softlimit < 0 || hardlimit < 0) {
 			if (getrlimit(rid, &lim_current)) {
 				lua_pushboolean(L, 0);
-				lua_pushstring(L, "getrlimit() failed.");
+				lua_pushstring(L, "getrlimit-failed");
 				return 2;
 			}
 		}
@@ -349,12 +349,13 @@
 		
 		if (setrlimit(rid, &lim)) {
 			lua_pushboolean(L, 0);
-			lua_pushstring(L, "setrlimit() failed.");
+			lua_pushstring(L, "setrlimit-failed");
 			return 2;
 		}
 	} else {
+		/* Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard. */
 		lua_pushboolean(L, 0);
-		lua_pushstring(L, "Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard.");
+		lua_pushstring(L, "invalid-resource");
 		return 2;
 	}
 	lua_pushboolean(L, 1);
@@ -369,7 +370,7 @@
 	
 	if (arguments != 1) {
 		lua_pushboolean(L, 0);
-		lua_pushstring(L, "I expect one argument only, the resource string.");
+		lua_pushstring(L, "invalid-arguments");
 		return 2;
 	}
 	
@@ -378,12 +379,13 @@
 	if (rid != -1) {
 		if (getrlimit(rid, &lim)) {
 			lua_pushboolean(L, 0);
-			lua_pushstring(L, "getrlimit() failed.");
+			lua_pushstring(L, "getrlimit-failed.");
 			return 2;
 		}
 	} else {
+		/* Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard. */
 		lua_pushboolean(L, 0);
-		lua_pushstring(L, "Unsupported resoucrce. Sorry I'm pretty limited by POSIX standard.");
+		lua_pushstring(L, "invalid-resource");
 		return 2;
 	}
 	lua_pushboolean(L, 1);

mercurial