| 670 | } |
| 671 | |
| 672 | static int dfhack_error(lua_State *L) |
| 673 | { |
| 674 | luaL_checkany(L, 1); |
| 675 | lua_settop(L, 3); |
| 676 | int level = std::max(1, luaL_optint(L, 2, 1)); |
| 677 | |
| 678 | lua_pushvalue(L, 1); |
| 679 | |
| 680 | if (convert_to_exception(L, level)) |
| 681 | { |
| 682 | luaL_where(L, level); |
| 683 | lua_setfield(L, -2, "where"); |
| 684 | |
| 685 | if (!lua_isnil(L, 3)) |
| 686 | { |
| 687 | lua_pushvalue(L, 3); |
| 688 | lua_setfield(L, -2, "verbose"); |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | return lua_error(L); |
| 693 | } |
| 694 | |
| 695 | // replaces os.exit with a thrown exception |
| 696 | static int dfhack_exit_error(lua_State *L) |
no test coverage detected