Have the XML parser warn about the error. Don't make every XML user have their own warning code.

This commit is contained in:
Chris Danford
2005-05-29 01:05:23 +00:00
parent 94a9cda191
commit ceef12b5cd
5 changed files with 32 additions and 29 deletions
+27 -13
View File
@@ -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