+ return *script_;
+ }
+
+
+ /**
+ * Throw an exception with a message formatted to communicate a
+ * type mismatch with the argument represented by this slot.
+ */
+ int raise_type_error(const std::string& expected) const
+ {
+ lua_Debug ar;
+ lua_getstack(script_->state_, 0, &ar);
+ lua_getinfo(script_->state_, "n", &ar);
+ const char* func = ar.name ? ar.name : "unknown function";
+
+ std::ostringstream stream;
+ stream << "bad argument " << index << " to '" << func
+ << "' (" << expected << " expected, got "
+ << type_name() << ")";
+
+ throw std::invalid_argument(stream.str());
+ return 0;
+ }
+
+ /**
+ * Throw a generic error concerning this particular slot.
+ */
+ int raise(const std::string& message) const
+ {
+ lua_Debug ar;
+ lua_getstack(script_->state_, 0, &ar);
+ lua_getinfo(script_->state_, "n", &ar);
+ const char* func = ar.name ? ar.name : "unknown function";
+
+ std::ostringstream stream;
+ stream << "bad argument " << index << " to '" << func
+ << "' (" << message << ")";
+
+ throw std::invalid_argument(stream.str());
+ return 0;