///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
| 495 | ////////////////////////////////////////////////////////////////////// |
| 496 | ////////////////////////////////////////////////////////////////////// |
| 497 | int CScriptSystem::ErrorHandler(lua_State *L) |
| 498 | { |
| 499 | const char *sFuncName = NULL; |
| 500 | const char *sSourceFile = NULL; |
| 501 | lua_Debug ar; |
| 502 | int nRes; |
| 503 | int iCurrentLine=-1; // no line number info |
| 504 | CScriptSystem *pThis = (CScriptSystem *)lua_touserdata(L, - 1); |
| 505 | |
| 506 | memset(&ar,0,sizeof(lua_Debug)); |
| 507 | |
| 508 | lua_pop(L, 1); |
| 509 | if (lua_isstring(L, 1)) |
| 510 | { |
| 511 | const char *sErr = lua_tostring(L, 1); |
| 512 | nRes = lua_getstack(L, 1, &ar); |
| 513 | |
| 514 | if (nRes != 0) |
| 515 | { |
| 516 | nRes = lua_getinfo(L, "lnS", &ar); |
| 517 | iCurrentLine=ar.currentline; |
| 518 | sFuncName = ar.name; |
| 519 | sSourceFile = ar.source; |
| 520 | } |
| 521 | if (!sFuncName) |
| 522 | sFuncName = "undefined"; |
| 523 | if (!sSourceFile) |
| 524 | sSourceFile= "undefined"; |
| 525 | |
| 526 | pThis->m_pSink->OnScriptError(sSourceFile, sFuncName, iCurrentLine, sErr); |
| 527 | } |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | ////////////////////////////////////////////////////////////////////// |
| 532 | ////////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected