1
0

lua_print_error.c 648 B

12345678910111213141516171819202122232425262728
  1. #include "private.h"
  2. void
  3. l_print_error(lua_State *L, const char *func, const char *when, int res)
  4. {
  5. switch (res) {
  6. case LUA_ERRRUN:
  7. printf("%s (%s):\n%s\n", func, when,
  8. lua_tostring(L, -1));
  9. break;
  10. case LUA_ERRSYNTAX:
  11. printf("%s (%s):\n%s\n", func, when,
  12. lua_tostring(L, -1));
  13. break;
  14. case LUA_ERRMEM:
  15. printf("%s (%s):\nmem alloc error\n", func, when);
  16. break;
  17. case LUA_ERRERR:
  18. printf("%s (%s):\nerror handler error\n", func, when);
  19. break;
  20. case LUA_ERRFILE:
  21. printf("%s (%s):\ncouldn't open file\n", func, when);
  22. break;
  23. default:
  24. printf("%s (%s):\nunknown error\n", func, when);
  25. break;
  26. }
  27. }