From 6b36579f15de18c1bfba25d718bec304b7f05c15 Mon Sep 17 00:00:00 2001 From: TotallyMehis Date: Sat, 4 Jul 2020 09:50:10 +0300 Subject: [PATCH] Log an error if failed to import run/zone data from db --- addons/sourcemod/scripting/influx_core/db_cb.sp | 10 +++++++++- addons/sourcemod/scripting/influx_zones/db_cb.sp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/sourcemod/scripting/influx_core/db_cb.sp b/addons/sourcemod/scripting/influx_core/db_cb.sp index be41dc92..d6613501 100644 --- a/addons/sourcemod/scripting/influx_core/db_cb.sp +++ b/addons/sourcemod/scripting/influx_core/db_cb.sp @@ -385,6 +385,7 @@ public void Thrd_GetRuns( Handle db, Handle res, const char[] szError, any data } + int runid; decl String:rundata[1024]; KeyValues kv; @@ -393,10 +394,17 @@ public void Thrd_GetRuns( Handle db, Handle res, const char[] szError, any data while ( SQL_FetchRow( res ) ) { + runid = SQL_FetchInt( res, 0 ); SQL_FetchString( res, 1, rundata, sizeof( rundata ) ); kv = new KeyValues( "" ); - kv.ImportFromString( rundata, "" ); + if ( !kv.ImportFromString( rundata, "" ) ) + { + LogError( INF_CON_PRE..."Failed to import run of id %i keyvalue data from database! Run data:\n%s", runid, rundata ); + + delete kv; + continue; + } LoadRunFromKv( kv ); diff --git a/addons/sourcemod/scripting/influx_zones/db_cb.sp b/addons/sourcemod/scripting/influx_zones/db_cb.sp index d51b1233..be0c383c 100644 --- a/addons/sourcemod/scripting/influx_zones/db_cb.sp +++ b/addons/sourcemod/scripting/influx_zones/db_cb.sp @@ -24,15 +24,23 @@ public void Thrd_GetZones( Handle db, Handle res, const char[] szError, any data decl String:zonedata[1024]; + int zoneid; KeyValues kv; while ( SQL_FetchRow( res ) ) { + zoneid = SQL_FetchInt( res, 0 ); SQL_FetchString( res, 1, zonedata, sizeof( zonedata ) ); kv = new KeyValues( "" ); - kv.ImportFromString( zonedata, "" ); + if ( !kv.ImportFromString( zonedata, "" ) ) + { + LogError( INF_CON_PRE..."Failed to import zone of id %i keyvalue data from database! Zone data:\n%s", zoneid, zonedata ); + + delete kv; + continue; + } LoadZoneFromKv( kv );