error handling improvements

update single
This commit is contained in:
ThePhD 2017-11-17 16:54:42 -05:00
parent 4a39020df9
commit 4256c07ee0
3 changed files with 11 additions and 9 deletions

View File

@ -20,8 +20,8 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2017-11-17 12:20:03.514818 UTC // Generated 2017-11-17 21:50:58.352644 UTC
// This header was generated with sol v2.18.6 (revision fa912a5) // This header was generated with sol v2.18.6 (revision 4a39020)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
@ -4949,7 +4949,7 @@ namespace sol {
userdata = LUA_TUSERDATA, userdata = LUA_TUSERDATA,
lightuserdata = LUA_TLIGHTUSERDATA, lightuserdata = LUA_TLIGHTUSERDATA,
table = LUA_TTABLE, table = LUA_TTABLE,
poly = none | lua_nil | string | number | thread | table | boolean | function | userdata | lightuserdata poly = -0xFFFF
}; };
inline const std::string& to_string(call_status c) { inline const std::string& to_string(call_status c) {
@ -5811,7 +5811,7 @@ namespace sol {
}; };
(void)detail::swallow{int(), (action(detail::demangle<Args>()), int())...}; (void)detail::swallow{int(), (action(detail::demangle<Args>()), int())...};
addendum += ")')"; addendum += ")')";
return type_panic_string(L, index, expected, actual, message + addendum); return type_panic_string(L, index, expected, actual, message.empty() ? addendum : message + addendum);
} }
}; };

View File

@ -84,21 +84,23 @@ namespace sol {
struct constructor_handler { struct constructor_handler {
int operator()(lua_State* L, int index, type expected, type actual, const std::string& message) const noexcept(false) { int operator()(lua_State* L, int index, type expected, type actual, const std::string& message) const noexcept(false) {
return type_panic_string(L, index, expected, actual, message + " (type check failed in constructor)"); std::string str = "(type check failed in constructor)";
return type_panic_string(L, index, expected, actual, message.empty() ? str : message + " " + str);
} }
}; };
template <typename F = void> template <typename F = void>
struct argument_handler { struct argument_handler {
int operator()(lua_State* L, int index, type expected, type actual, const std::string& message) const noexcept(false) { int operator()(lua_State* L, int index, type expected, type actual, const std::string& message) const noexcept(false) {
return type_panic_string(L, index, expected, actual, message + " (bad argument to variable or function call)"); std::string str = "(bad argument to variable or function call)";
return type_panic_string(L, index, expected, actual, message.empty() ? str : message + " " + str );
} }
}; };
template <typename R, typename... Args> template <typename R, typename... Args>
struct argument_handler<types<R, Args...>> { struct argument_handler<types<R, Args...>> {
int operator()(lua_State* L, int index, type expected, type actual, const std::string& message) const noexcept(false) { int operator()(lua_State* L, int index, type expected, type actual, const std::string& message) const noexcept(false) {
std::string addendum = " (bad argument into '"; std::string addendum = "(bad argument into '";
addendum += detail::demangle<R>(); addendum += detail::demangle<R>();
addendum += "("; addendum += "(";
int marker = 0; int marker = 0;
@ -111,7 +113,7 @@ namespace sol {
}; };
(void)detail::swallow{int(), (action(detail::demangle<Args>()), int())...}; (void)detail::swallow{int(), (action(detail::demangle<Args>()), int())...};
addendum += ")')"; addendum += ")')";
return type_panic_string(L, index, expected, actual, message + addendum); return type_panic_string(L, index, expected, actual, message.empty() ? addendum : message + " " + addendum);
} }
}; };

View File

@ -617,7 +617,7 @@ namespace sol {
userdata = LUA_TUSERDATA, userdata = LUA_TUSERDATA,
lightuserdata = LUA_TLIGHTUSERDATA, lightuserdata = LUA_TLIGHTUSERDATA,
table = LUA_TTABLE, table = LUA_TTABLE,
poly = none | lua_nil | string | number | thread | table | boolean | function | userdata | lightuserdata poly = -0xFFFF
}; };
inline const std::string& to_string(call_status c) { inline const std::string& to_string(call_status c) {