Be more verbose when finding an error

Try to give the user more information about what the actual file error
is, rather than immediately throwing the IO_ERROR
This commit is contained in:
Seth Hillbrand 2022-08-18 11:53:11 -07:00
parent 3050b987ee
commit c53fe1c1f0
1 changed files with 24 additions and 2 deletions

View File

@ -187,9 +187,20 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
name = FromUTF8();
LIB_ID id;
int bad_pos = id.Parse( name );
if( id.Parse( name ) >= 0 )
if( bad_pos >= 0 )
{
if( static_cast<int>( name.size() ) > bad_pos )
{
wxString msg = wxString::Format(
_( "Symbol %s contains invalid character '%c'" ), name,
name[bad_pos] );
THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
THROW_PARSE_ERROR( _( "Invalid library identifier" ), CurSource(), CurLine(),
CurLineNumber(), CurOffset() );
}
@ -2443,9 +2454,20 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
Expecting( "symbol|number" );
LIB_ID libId;
wxString name = FromUTF8();
int bad_pos = libId.Parse( name );
if( libId.Parse( FromUTF8() ) >= 0 )
if( bad_pos >= 0 )
{
if( static_cast<int>( name.size() ) > bad_pos )
{
wxString msg = wxString::Format(
_( "Symbol %s contains invalid character '%c'" ), name,
name[bad_pos] );
THROW_PARSE_ERROR( msg, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
}
THROW_PARSE_ERROR( _( "Invalid symbol library ID" ), CurSource(), CurLine(),
CurLineNumber(), CurOffset() );
}