Merge pull request #448 from alliedmodders/use-blamepluginerror

Update SP and use BlamePluginError in sdkhooks and sdktools.
This commit is contained in:
Fyren
2015-11-18 18:33:10 -07:00
4 changed files with 60 additions and 38 deletions
+51 -29
View File
@@ -157,44 +157,66 @@ int DebugReport::_GetPluginIndex(IPluginContext *ctx)
void DebugReport::ReportError(const IErrorReport &report, IFrameIterator &iter)
{
// Find the nearest plugin to blame.
const char *blame = nullptr;
for (; !iter.Done(); iter.Next()) {
if (iter.IsScriptedFrame()) {
IPlugin *plugin = pluginsys->FindPluginByContext(iter.Context()->GetContext());
if (plugin)
blame = plugin->GetFilename();
else
blame = iter.Context()->GetRuntime()->GetFilename();
break;
if (report.Blame())
{
blame = report.Blame()->DebugName();
} else {
// Find the nearest plugin to blame.
for (; !iter.Done(); iter.Next())
{
if (iter.IsScriptedFrame())
{
IPlugin *plugin = pluginsys->FindPluginByContext(iter.Context()->GetContext());
if (plugin)
{
blame = plugin->GetFilename();
} else {
blame = iter.Context()->GetRuntime()->GetFilename();
}
break;
}
}
}
iter.Reset();
g_Logger.LogError("[SM] Exception reported: %s", report.Message());
if (blame)
g_Logger.LogError("[SM] Blaming plugin: %s", blame);
g_Logger.LogError("[SM] Call stack trace:");
for (int index = 0; !iter.Done(); iter.Next(), index++) {
const char *fn = iter.FunctionName();
if (!fn)
fn = "<unknown function>";
if (blame)
{
g_Logger.LogError("[SM] Blaming: %s()", blame);
}
if (iter.IsNativeFrame()) {
g_Logger.LogError("[SM] [%d] %s", index, fn);
continue;
}
if (iter.IsScriptedFrame()) {
const char *file = iter.FilePath();
if (!file)
file = "<unknown>";
g_Logger.LogError("[SM] [%d] Line %d, %s::%s()",
index,
iter.LineNumber(),
file,
fn);
if (!iter.Done())
{
g_Logger.LogError("[SM] Call stack trace:");
for (int index = 0; !iter.Done(); iter.Next(), index++)
{
const char *fn = iter.FunctionName();
if (!fn)
{
fn = "<unknown function>";
}
if (iter.IsNativeFrame())
{
g_Logger.LogError("[SM] [%d] %s", index, fn);
continue;
}
if (iter.IsScriptedFrame())
{
const char *file = iter.FilePath();
if (!file)
{
file = "<unknown>";
}
g_Logger.LogError("[SM] [%d] Line %d, %s::%s()",
index,
iter.LineNumber(),
file,
fn);
}
}
}
}