From e2932fb61a339235ad6c5934a4459feff242f9c8 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 18 Aug 2006 19:02:37 +0000 Subject: [PATCH] Request am40967 (logging set_fail_state) --- amxmodx/amxmodx.cpp | 5 +++++ amxmodx/debugger.cpp | 7 ++++++- amxmodx/modules.cpp | 14 +++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index e81bdb8b..9e9b472d 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -3719,6 +3719,11 @@ static cell AMX_NATIVE_CALL set_fail_state(AMX *amx, cell *params) pPlugin->setStatus(ps_error); pPlugin->setError(str); + AMXXLOG_Error("[AMXX] Plugin (\"%s\") is setting itself as failed.", pPlugin->getName()); + AMXXLOG_Error("[AMXX] Plugin says: %s", str); + + LogError(amx, AMX_ERR_EXIT, NULL); + //plugin dies once amx_Exec concludes return 0; } diff --git a/amxmodx/debugger.cpp b/amxmodx/debugger.cpp index f850ea09..e9b9050d 100755 --- a/amxmodx/debugger.cpp +++ b/amxmodx/debugger.cpp @@ -622,7 +622,12 @@ void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLengt } } - _snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename); + if (error == AMX_ERR_EXIT) + { + _snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - %s", error, filename, GenericError(AMX_ERR_EXIT)); + } else { + _snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename); + } } void Debugger::GenericMessage(AMX *amx, int err) diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 0ae28906..723da268 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -1537,7 +1537,9 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...) #if defined BINLOG_ENABLED CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(amx); if (pl) + { g_BinLog.WriteOp(BinLog_NativeError, pl->getId(), err, msg_buffer); + } #endif //give the plugin first chance to handle any sort of error @@ -1546,14 +1548,19 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...) if (pHandler->InNativeFilter()) { if (pDebugger) + { pDebugger->EndExec(); + } } else { if (pHandler) { if (pHandler->IsHandling()) { if (fmt != NULL) + { pHandler->SetErrorMsg(msg_buffer); + } + return; } @@ -1569,10 +1576,15 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...) if (!pDebugger) { if (fmt) + { AMXXLOG_Error("%s", msg_buffer); + } Debugger::GenericMessage(amx, err); - AMXXLOG_Error("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes)."); + if (err != AMX_ERR_EXIT) + { + AMXXLOG_Error("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes)."); + } //destroy original error code so the original is not displayed again } else { pDebugger->SetTracedError(err);