You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.h 925B

123456789101112131415161718192021222324
  1. #ifndef _ERROR_H_
  2. #define _ERROR_H_
  3. #include "luaT.h"
  4. #include <string.h>
  5. static inline int _lua_error(lua_State *L, int ret, const char* file, int line) {
  6. int pos_ret = ret >= 0 ? ret : -ret;
  7. return luaL_error(L, "ERROR: (%s, %d): (%d, %s)\n", file, line, pos_ret, strerror(pos_ret));
  8. }
  9. static inline int _lua_error_str(lua_State *L, const char *str, const char* file, int line) {
  10. return luaL_error(L, "ERROR: (%s, %d): (%s)\n", file, line, str);
  11. }
  12. static inline int _lua_error_str_str(lua_State *L, const char *str, const char* file, int line, const char *extra) {
  13. return luaL_error(L, "ERROR: (%s, %d): (%s: %s)\n", file, line, str, extra);
  14. }
  15. #define LUA_HANDLE_ERROR(L, ret) _lua_error(L, ret, __FILE__, __LINE__)
  16. #define LUA_HANDLE_ERROR_STR(L, str) _lua_error_str(L, str, __FILE__, __LINE__)
  17. #define LUA_HANDLE_ERROR_STR_STR(L, str, extra) _lua_error_str_str(L, str, __FILE__, __LINE__, extra)
  18. #endif