+ /**
+ * Check the value and throw an error if its the wrong type. There's a
+ * little caveat: This method never returns because it does a long jump.
+ * Consequently, constructed C++ objects which exist on the stack
+ * between the current frame and some lua function will not be
+ * destructed. That's not a problem for objects that only exist on the
+ * stack, but any objects that allocate memory on the heap (such as
+ * containers or strings) will leak. Therefore, you should only call
+ * this method after cleaning up such objects. The best thing to do for
+ * defining functions is to simply check all the parameters at the
+ * get-go before any C++ objects are even constructed.
+ */
+
+ void requireType(Type type) const
+ {
+ if (type != getType())
+ {
+ luaL_typerror(state, index, lua_typename(state, type));
+ }
+ }
+
+ void throwError(const char* error)
+ {
+ luaL_argerror(state, index, error);
+ }
+
+
+ Value& requireBoolean()
+ {
+ if (!isBoolean()) luaL_typerror(state, index, "boolean");
+ return *this;
+ }
+ Value& requireNumber()
+ {
+ if (!isNumber()) luaL_typerror(state, index, "number");
+ return *this;
+ }
+ Value& requireString()
+ {
+ if (!isString()) luaL_typerror(state, index, "string");
+ return *this;
+ }
+ Value& requireTable()
+ {
+ if (!isTable()) luaL_typerror(state, index, "table");
+ return *this;
+ }
+ Value& requireFunction()
+ {
+ if (!isFunction()) luaL_typerror(state, index, "function");
+ return *this;
+ }
+ Value& requireData()
+ {
+ if (!isData()) luaL_typerror(state, index, "data");
+ return *this;
+ }
+ Value& requireNil()
+ {
+ if (!isNil()) luaL_typerror(state, index, "nil");
+ return *this;
+ }
+ Value& requireThread()
+ {
+ if (!isThread()) luaL_typerror(state, index, "thread");
+ return *this;
+ }
+
+