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;
|
return;
|
||||||
|
|
||||||
XNode xml;
|
XNode xml;
|
||||||
PARSEINFO pi;
|
if( !xml.LoadFromFile(COINS_DAT) )
|
||||||
if( !xml.LoadFromFile(COINS_DAT, &pi) )
|
|
||||||
{
|
|
||||||
LOG->Warn( "Error parsing file \"%s\": %s", COINS_DAT.c_str(), pi.error_string.c_str() );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
LoadFromNode( &xml );
|
LoadFromNode( &xml );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -783,12 +783,8 @@ Profile::LoadResult Profile::LoadAllFromDir( CString sDir, bool bRequireSignatur
|
|||||||
|
|
||||||
LOG->Trace( "Loading %s", fn.c_str() );
|
LOG->Trace( "Loading %s", fn.c_str() );
|
||||||
XNode xml;
|
XNode xml;
|
||||||
PARSEINFO pi;
|
if( !xml.LoadFromFile(fn) )
|
||||||
if( !xml.LoadFromFile( fn, &pi ) )
|
|
||||||
{
|
|
||||||
LOG->Warn( "Error parsing file '%s': %s", fn.c_str(), pi.error_string.c_str() );
|
|
||||||
return failed_tampered;
|
return failed_tampered;
|
||||||
}
|
|
||||||
LOG->Trace( "Done." );
|
LOG->Trace( "Done." );
|
||||||
|
|
||||||
return LoadStatsXmlFromNode( &xml );
|
return LoadStatsXmlFromNode( &xml );
|
||||||
|
|||||||
@@ -58,13 +58,10 @@ void Transition::Load( CString sBGAniDir )
|
|||||||
{
|
{
|
||||||
CString sSoundFile;
|
CString sSoundFile;
|
||||||
XNode xml;
|
XNode xml;
|
||||||
PARSEINFO pi;
|
xml.LoadFromFile( sBGAniDir );
|
||||||
xml.LoadFromFile( sBGAniDir, &pi );
|
|
||||||
if( xml.GetAttrValue( "Sound", sSoundFile ) )
|
if( xml.GetAttrValue( "Sound", sSoundFile ) )
|
||||||
{
|
|
||||||
m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
|
m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+27
-13
@@ -8,6 +8,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "DateTime.h"
|
#include "DateTime.h"
|
||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
|
#include "arch/Dialog/Dialog.h"
|
||||||
|
|
||||||
|
|
||||||
static const char chXMLTagOpen = '<';
|
static const char chXMLTagOpen = '<';
|
||||||
@@ -1036,7 +1037,7 @@ CString XEntity2Ref( const char* str )
|
|||||||
return entityDefault.Entity2Ref( str );
|
return entityDefault.Entity2Ref( str );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi )
|
bool XNode::LoadFromFile( const CString &sFile )
|
||||||
{
|
{
|
||||||
RageFile f;
|
RageFile f;
|
||||||
if( !f.Open(sFile, RageFile::READ) )
|
if( !f.Open(sFile, RageFile::READ) )
|
||||||
@@ -1045,26 +1046,39 @@ bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi )
|
|||||||
return false;
|
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;
|
CString s;
|
||||||
if( f.Read( s ) == -1 )
|
if( f.Read( s ) == -1 )
|
||||||
{
|
{
|
||||||
if( pi )
|
pi.error_occur = true;
|
||||||
{
|
pi.error_pointer = NULL;
|
||||||
pi->error_occur = true;
|
pi.error_code = PIE_READ_ERROR;
|
||||||
pi->error_pointer = NULL;
|
pi.error_string = f.GetError();
|
||||||
pi->error_code = PIE_READ_ERROR;
|
|
||||||
pi->error_string = f.GetError();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
goto error;
|
||||||
}
|
}
|
||||||
this->Load( s, pi );
|
this->Load( s, &pi );
|
||||||
return !pi->error_occur;
|
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
|
bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const
|
||||||
|
|||||||
@@ -171,8 +171,8 @@ struct XNode
|
|||||||
char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi );
|
char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi );
|
||||||
bool GetXML( RageFileBasic &f, DISP_OPT *opt ) const;
|
bool GetXML( RageFileBasic &f, DISP_OPT *opt ) const;
|
||||||
|
|
||||||
bool LoadFromFile( const CString &sFile, PARSEINFO *pi );
|
bool LoadFromFile( const CString &sFile );
|
||||||
bool LoadFromFile( RageFileBasic &f, PARSEINFO *pi );
|
bool LoadFromFile( RageFileBasic &f );
|
||||||
bool SaveToFile( const CString &sFile, DISP_OPT *opt ) const;
|
bool SaveToFile( const CString &sFile, DISP_OPT *opt ) const;
|
||||||
bool SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const;
|
bool SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user