Have the XML parser warn about the error. Don't make every XML user have their own warning code.
This commit is contained in:
@@ -122,12 +122,8 @@ void Bookkeeper::ReadFromDisk()
|
||||
return;
|
||||
|
||||
XNode xml;
|
||||
PARSEINFO pi;
|
||||
if( !xml.LoadFromFile(COINS_DAT, &pi) )
|
||||
{
|
||||
LOG->Warn( "Error parsing file \"%s\": %s", COINS_DAT.c_str(), pi.error_string.c_str() );
|
||||
if( !xml.LoadFromFile(COINS_DAT) )
|
||||
return;
|
||||
}
|
||||
|
||||
LoadFromNode( &xml );
|
||||
}
|
||||
|
||||
@@ -783,12 +783,8 @@ Profile::LoadResult Profile::LoadAllFromDir( CString sDir, bool bRequireSignatur
|
||||
|
||||
LOG->Trace( "Loading %s", fn.c_str() );
|
||||
XNode xml;
|
||||
PARSEINFO pi;
|
||||
if( !xml.LoadFromFile( fn, &pi ) )
|
||||
{
|
||||
LOG->Warn( "Error parsing file '%s': %s", fn.c_str(), pi.error_string.c_str() );
|
||||
if( !xml.LoadFromFile(fn) )
|
||||
return failed_tampered;
|
||||
}
|
||||
LOG->Trace( "Done." );
|
||||
|
||||
return LoadStatsXmlFromNode( &xml );
|
||||
|
||||
@@ -58,12 +58,9 @@ void Transition::Load( CString sBGAniDir )
|
||||
{
|
||||
CString sSoundFile;
|
||||
XNode xml;
|
||||
PARSEINFO pi;
|
||||
xml.LoadFromFile( sBGAniDir, &pi );
|
||||
xml.LoadFromFile( sBGAniDir );
|
||||
if( xml.GetAttrValue( "Sound", sSoundFile ) )
|
||||
{
|
||||
m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-13
@@ -8,6 +8,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "DateTime.h"
|
||||
#include "Foreach.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
|
||||
|
||||
static const char chXMLTagOpen = '<';
|
||||
@@ -1036,7 +1037,7 @@ CString XEntity2Ref( const char* str )
|
||||
return entityDefault.Entity2Ref( str );
|
||||
}
|
||||
|
||||
bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi )
|
||||
bool XNode::LoadFromFile( const CString &sFile )
|
||||
{
|
||||
RageFile f;
|
||||
if( !f.Open(sFile, RageFile::READ) )
|
||||
@@ -1045,26 +1046,39 @@ bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi )
|
||||
return false;
|
||||
}
|
||||
|
||||
return LoadFromFile( f, pi );
|
||||
bool bSuccess = LoadFromFile( f );
|
||||
if( !bSuccess )
|
||||
{
|
||||
CString sWarning = ssprintf( "XML: LoadFromFile failed for file: %s", sFile.c_str() );
|
||||
LOG->Warn( sWarning );
|
||||
Dialog::OK( sWarning, "XML_PARSE_ERROR" );
|
||||
}
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
bool XNode::LoadFromFile( RageFileBasic &f, PARSEINFO *pi )
|
||||
bool XNode::LoadFromFile( RageFileBasic &f )
|
||||
{
|
||||
PARSEINFO pi;
|
||||
CString s;
|
||||
if( f.Read( s ) == -1 )
|
||||
{
|
||||
if( pi )
|
||||
{
|
||||
pi->error_occur = true;
|
||||
pi->error_pointer = NULL;
|
||||
pi->error_code = PIE_READ_ERROR;
|
||||
pi->error_string = f.GetError();
|
||||
}
|
||||
pi.error_occur = true;
|
||||
pi.error_pointer = NULL;
|
||||
pi.error_code = PIE_READ_ERROR;
|
||||
pi.error_string = f.GetError();
|
||||
|
||||
return false;
|
||||
goto error;
|
||||
}
|
||||
this->Load( s, pi );
|
||||
return !pi->error_occur;
|
||||
this->Load( s, &pi );
|
||||
if( pi.error_occur )
|
||||
goto error;
|
||||
return true;
|
||||
|
||||
error:
|
||||
CString sWarning = ssprintf( "XML: LoadFromFile failed: %s", pi.error_string.c_str() );
|
||||
LOG->Warn( sWarning );
|
||||
Dialog::OK( sWarning, "XML_PARSE_ERROR" );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const
|
||||
|
||||
@@ -171,8 +171,8 @@ struct XNode
|
||||
char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi );
|
||||
bool GetXML( RageFileBasic &f, DISP_OPT *opt ) const;
|
||||
|
||||
bool LoadFromFile( const CString &sFile, PARSEINFO *pi );
|
||||
bool LoadFromFile( RageFileBasic &f, PARSEINFO *pi );
|
||||
bool LoadFromFile( const CString &sFile );
|
||||
bool LoadFromFile( RageFileBasic &f );
|
||||
bool SaveToFile( const CString &sFile, DISP_OPT *opt ) const;
|
||||
bool SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user