| 1536 | } |
| 1537 | |
| 1538 | bool AppFrame::SafeCallScript(const char* source, size_t len, const char* desc)LNOEXCEPT |
| 1539 | { |
| 1540 | lua_pushcfunction(L, StackTraceback); |
| 1541 | |
| 1542 | if (0 != luaL_loadbuffer(L, source, len, desc)) |
| 1543 | { |
| 1544 | try |
| 1545 | { |
| 1546 | wstring tErrorInfo = StringFormat( |
| 1547 | L"脚本'%m'编译失败: %m", |
| 1548 | desc, |
| 1549 | lua_tostring(L, -1) |
| 1550 | ); |
| 1551 | |
| 1552 | LERROR("脚本错误:%s", tErrorInfo.c_str()); |
| 1553 | MessageBox( |
| 1554 | m_pMainWindow ? (HWND)m_pMainWindow->GetHandle() : 0, |
| 1555 | tErrorInfo.c_str(), |
| 1556 | L"LuaSTGPlus脚本错误", |
| 1557 | MB_ICONERROR | MB_OK |
| 1558 | ); |
| 1559 | } |
| 1560 | catch (const bad_alloc&) |
| 1561 | { |
| 1562 | LERROR("尝试写出脚本错误时发生内存不足错误"); |
| 1563 | } |
| 1564 | |
| 1565 | lua_pop(L, 2); |
| 1566 | return false; |
| 1567 | } |
| 1568 | |
| 1569 | if (0 != lua_pcall(L, 0, 0, lua_gettop(L) - 1)) |
| 1570 | { |
| 1571 | try |
| 1572 | { |
| 1573 | wstring tErrorInfo = StringFormat( |
| 1574 | L"脚本'%m'中产生未处理的运行时错误:\n\t%m", |
| 1575 | desc, |
| 1576 | lua_tostring(L, -1) |
| 1577 | ); |
| 1578 | |
| 1579 | LERROR("脚本错误:%s", tErrorInfo.c_str()); |
| 1580 | MessageBox( |
| 1581 | m_pMainWindow ? (HWND)m_pMainWindow->GetHandle() : 0, |
| 1582 | tErrorInfo.c_str(), |
| 1583 | L"LuaSTGPlus脚本错误", |
| 1584 | MB_ICONERROR | MB_OK |
| 1585 | ); |
| 1586 | } |
| 1587 | catch (const bad_alloc&) |
| 1588 | { |
| 1589 | LERROR("尝试写出脚本错误时发生内存不足错误"); |
| 1590 | } |
| 1591 | |
| 1592 | lua_pop(L, 2); |
| 1593 | return false; |
| 1594 | } |
| 1595 |
nothing calls this directly
no outgoing calls
no test coverage detected