More error message regularization (and translatability improvements).

This commit is contained in:
Jeff Young 2021-06-28 00:26:54 +01:00
parent 08fb05e522
commit 062c4fda62
17 changed files with 131 additions and 193 deletions

View File

@ -59,10 +59,10 @@ void IO_ERROR::init( const wxString& aProblem, const char* aThrowersFile,
// a short filename will be printed (it is better for user, the full filename has no meaning). // a short filename will be printed (it is better for user, the full filename has no meaning).
wxString srcname = aThrowersFile; wxString srcname = aThrowersFile;
where.Printf( _( "from %s : %s() line:%d" ), where.Printf( _( "from %s : %s() line %d" ),
srcname.AfterLast( '/' ), srcname.AfterLast( '/' ),
wxString( aThrowersFunction ), wxString( aThrowersFunction ),
aThrowersLineNumber ); aThrowersLineNumber );
} }
@ -73,7 +73,7 @@ void PARSE_ERROR::init( const wxString& aProblem, const char* aThrowersFile,
{ {
parseProblem = aProblem; parseProblem = aProblem;
problem.Printf( _( "%s in \"%s\", line %d, offset %d" ), problem.Printf( _( "%s in '%s', line %d, offset %d." ),
aProblem, aProblem,
aSource, aSource,
aLineNumber, aLineNumber,

View File

@ -489,7 +489,7 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable )
if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) )
{ {
THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path \"%s\"." ), THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ),
fn.GetPath() ) ); fn.GetPath() ) );
} }

View File

@ -375,7 +375,7 @@ void KiCopyFile( const wxString& aSrcPath, const wxString& aDestPath, wxString&
if( !aErrors.IsEmpty() ) if( !aErrors.IsEmpty() )
aErrors += "\n"; aErrors += "\n";
msg.Printf( _( "Cannot copy file \"%s\"." ), aDestPath ); msg.Printf( _( "Cannot copy file '%s'." ), aDestPath );
aErrors += msg; aErrors += msg;
} }
} }

View File

@ -250,8 +250,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
// here and catching it in the KiCad launcher resolves the crash issue. See bug // here and catching it in the KiCad launcher resolves the crash issue. See bug
// report https://bugs.launchpad.net/kicad/+bug/1577786. // report https://bugs.launchpad.net/kicad/+bug/1577786.
msg.Printf( _( "Failed to load kiface library \"%s\"." ), msg.Printf( _( "Failed to load kiface library '%s'." ), dname );
dname );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == NULL ) else if( ( addr = dso.GetSymbol( wxT( KIFACE_INSTANCE_NAME_AND_VERSION ) ) ) == NULL )
@ -259,8 +258,7 @@ KIFACE* KIWAY::KiFACE( FACE_T aFaceId, bool doLoad )
// Failure: error reporting UI was done via wxLogSysError(). // Failure: error reporting UI was done via wxLogSysError().
// No further reporting required here. Assume the same thing applies here as // No further reporting required here. Assume the same thing applies here as
// above with the Load() call. This has not been tested. // above with the Load() call. This has not been tested.
msg.Printf( _( "Could not read instance name and version symbol from kiface " msg.Printf( _( "Could not read instance name and version from kiface library '%s'." ),
"library \"%s\"." ),
dname ); dname );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }

View File

@ -25,10 +25,8 @@
void LaunchExternal( const wxString& aPath ) void LaunchExternal( const wxString& aPath )
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
wxString msg;
// Quote in case there are spaces in the path. // Quote in case there are spaces in the path.
msg.Printf( "open \"%s\"", aPath ); wxString msg = "open \"" + aPath + "\"";
system( msg.c_str() ); system( msg.c_str() );
#else #else

View File

@ -108,7 +108,7 @@ bool PROJECT_ARCHIVER::Unarchive( const wxString& aSrcFile, const wxString& aDes
for( wxArchiveEntry* entry = archiveStream->GetNextEntry(); entry; for( wxArchiveEntry* entry = archiveStream->GetNextEntry(); entry;
entry = archiveStream->GetNextEntry() ) entry = archiveStream->GetNextEntry() )
{ {
fileStatus.Printf( _( "Extracting file \"%s\"\n" ), entry->GetName() ); fileStatus.Printf( _( "Extracting file '%s'.\n" ), entry->GetName() );
aReporter.Report( fileStatus, RPT_SEVERITY_INFO ); aReporter.Report( fileStatus, RPT_SEVERITY_INFO );
wxString fullname = aDestDir + entry->GetName(); wxString fullname = aDestDir + entry->GetName();
@ -205,7 +205,7 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
if( !ostream.IsOk() ) // issue to create the file. Perhaps not writable dir if( !ostream.IsOk() ) // issue to create the file. Perhaps not writable dir
{ {
msg.Printf( _( "Unable to create archive file \"%s\"\n" ), aDestFile ); msg.Printf( _( "Unable to create archive file '%s'.\n" ), aDestFile );
aReporter.Report( msg, RPT_SEVERITY_ERROR ); aReporter.Report( msg, RPT_SEVERITY_ERROR );
return false; return false;
} }
@ -251,7 +251,7 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
if( aVerbose ) if( aVerbose )
{ {
msg.Printf( _( "Archive file \"%s\"\n" ), currFilename ); msg.Printf( _( "Archived file '%s'.\n" ), currFilename );
aReporter.Report( msg, RPT_SEVERITY_INFO ); aReporter.Report( msg, RPT_SEVERITY_INFO );
} }
@ -261,7 +261,7 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
{ {
if( aVerbose ) if( aVerbose )
{ {
msg.Printf( _( "Archive file \"%s\": Failed!\n" ), currFilename ); msg.Printf( _( "Failed to archive file '%s'.\n" ), currFilename );
aReporter.Report( msg, RPT_SEVERITY_ERROR ); aReporter.Report( msg, RPT_SEVERITY_ERROR );
} }
@ -287,13 +287,15 @@ bool PROJECT_ARCHIVER::Archive( const wxString& aSrcDir, const wxString& aDestFi
if( zipstream.Close() ) if( zipstream.Close() )
{ {
msg.Printf( _( "Zip archive \"%s\" created (%s uncompressed, %s compressed)\n" ), aDestFile, msg.Printf( _( "Zip archive '%s' created (%s uncompressed, %s compressed).\n" ),
reportSize( uncompressedBytes ), reportSize( zipBytesCnt ) ); aDestFile,
reportSize( uncompressedBytes ),
reportSize( zipBytesCnt ) );
aReporter.Report( msg, RPT_SEVERITY_INFO ); aReporter.Report( msg, RPT_SEVERITY_INFO );
} }
else else
{ {
msg.Printf( wxT( "Unable to create archive \"%s\"\n" ), aDestFile ); msg.Printf( wxT( "Unable to create archive '%s'.\n" ), aDestFile );
aReporter.Report( msg, RPT_SEVERITY_ERROR ); aReporter.Report( msg, RPT_SEVERITY_ERROR );
success = false; success = false;
} }

View File

@ -299,7 +299,7 @@ bool LIB_ID_VALIDATOR::Validate( wxWindow *aParent )
} }
else if( dummy.Parse( val ) != -1 || !dummy.IsValid() ) // Is valid LIB_ID. else if( dummy.Parse( val ) != -1 || !dummy.IsValid() ) // Is valid LIB_ID.
{ {
msg.Printf( _( "\"%s\" is not a valid library identifier format." ), val ); msg.Printf( _( "'%s' is not a valid library identifier format." ), val );
} }
if( !msg.empty() ) if( !msg.empty() )

View File

@ -172,9 +172,8 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid symbol name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid symbol name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
name = FromUTF8(); name = FromUTF8();
@ -183,9 +182,8 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( id.Parse( name ) >= 0 ) if( id.Parse( name ) >= 0 )
{ {
error.Printf( _( "Invalid library identifier in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid library identifier" ), CurSource(), CurLine(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
m_symbolName = id.GetLibItemName().wx_str(); m_symbolName = id.GetLibItemName().wx_str();
@ -256,10 +254,8 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( THROW_PARSE_ERROR( _( "Invalid parent symbol name" ), CurSource(), CurLine(),
_( "Invalid symbol extends name in\nfile: \"%s\"\nline: %d\noffset: %d" ), CurLineNumber(), CurOffset() );
CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
name = FromUTF8(); name = FromUTF8();
@ -267,10 +263,8 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( it == aSymbolLibMap.end() ) if( it == aSymbolLibMap.end() )
{ {
error.Printf( error.Printf( _( "No parent for extended symbol %s" ), name.c_str() );
_( "No parent for extended symbol %s in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
name.c_str(), CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
symbol->SetParent( it->second ); symbol->SetParent( it->second );
@ -284,21 +278,16 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( THROW_PARSE_ERROR( _( "Invalid symbol unit name" ), CurSource(), CurLine(),
_( "Invalid symbol unit name in\nfile: \"%s\"\nline: %d\noffset: %d" ), CurLineNumber(), CurOffset() );
CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
name = FromUTF8(); name = FromUTF8();
if( !name.StartsWith( m_symbolName ) ) if( !name.StartsWith( m_symbolName ) )
{ {
error.Printf( error.Printf( _( "Invalid symbol unit name prefix %s" ), name.c_str() );
_( "Invalid symbol unit name prefix %s in\nfile: \"%s\"\n" THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
"line: %d\noffset: %d" ),
name.c_str(), CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
name = name.Right( name.Length() - m_symbolName.Length() - 1 ); name = name.Right( name.Length() - m_symbolName.Length() - 1 );
@ -307,29 +296,22 @@ LIB_SYMBOL* SCH_SEXPR_PARSER::ParseSymbol( LIB_SYMBOL_MAP& aSymbolLibMap, int aF
if( tokenizer.CountTokens() != 2 ) if( tokenizer.CountTokens() != 2 )
{ {
error.Printf( error.Printf( _( "Invalid symbol unit name suffix %s" ), name.c_str() );
_( "Invalid symbol unit name suffix %s in\nfile: \"%s\"\n" THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
"line: %d\noffset: %d" ),
name.c_str(), CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
if( !tokenizer.GetNextToken().ToLong( &tmp ) ) if( !tokenizer.GetNextToken().ToLong( &tmp ) )
{ {
error.Printf( error.Printf( _( "Invalid symbol unit number %s" ), name.c_str() );
_( "Invalid symbol unit number %s in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
name.c_str(), CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
m_unit = static_cast<int>( tmp ); m_unit = static_cast<int>( tmp );
if( !tokenizer.GetNextToken().ToLong( &tmp ) ) if( !tokenizer.GetNextToken().ToLong( &tmp ) )
{ {
error.Printf( error.Printf( _( "Invalid symbol convert number %s" ), name.c_str() );
_( "Invalid symbol convert number %s in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( error, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
name.c_str(), CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
m_convert = static_cast<int>( tmp ); m_convert = static_cast<int>( tmp );
@ -445,16 +427,12 @@ LIB_ITEM* SCH_SEXPR_PARSER::ParseDrawItem()
double SCH_SEXPR_PARSER::parseDouble() double SCH_SEXPR_PARSER::parseDouble()
{ {
char* tmp; char* tmp;
wxString error;
// In case the file got saved with the wrong locale. // In case the file got saved with the wrong locale.
if( strchr( CurText(), ',' ) != NULL ) if( strchr( CurText(), ',' ) != NULL )
{ {
error.Printf( _( "Floating point number with incorrect local in\nfile: \"%s\"\n" THROW_PARSE_ERROR( _( "Floating point number with incorrect locale" ), CurSource(),
"line: %d\noffset: %d" ), CurLine(), CurLineNumber(), CurOffset() );
CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
errno = 0; errno = 0;
@ -463,18 +441,14 @@ double SCH_SEXPR_PARSER::parseDouble()
if( errno ) if( errno )
{ {
error.Printf( _( "Invalid floating point number in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid floating point number" ), CurSource(), CurLine(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
if( CurText() == tmp ) if( CurText() == tmp )
{ {
error.Printf( _( "Missing floating point number in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Missing floating point number" ), CurSource(), CurLine(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
return fval; return fval;
@ -774,11 +748,8 @@ void SCH_SEXPR_PARSER::parsePinNames( std::unique_ptr<LIB_SYMBOL>& aSymbol )
} }
else if( token != T_RIGHT ) else if( token != T_RIGHT )
{ {
error.Printf( _( "Invalid symbol names definition in\nfile: '%s'\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid pin names definition" ), CurSource(), CurLine(),
CurSource().c_str(), CurLineNumber(), CurOffset() );
CurLineNumber(),
CurOffset() );
THROW_IO_ERROR( error );
} }
} }
@ -799,22 +770,16 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid property name in\nfile: '%s'\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid property name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurOffset() );
CurLineNumber(),
CurOffset() );
THROW_IO_ERROR( error );
} }
name = FromUTF8(); name = FromUTF8();
if( name.IsEmpty() ) if( name.IsEmpty() )
{ {
error.Printf( _( "Empty property name in\nfile: '%s'\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Empty property name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurOffset() );
CurLineNumber(),
CurOffset() );
THROW_IO_ERROR( error );
} }
field->SetName( name ); field->SetName( name );
@ -822,11 +787,8 @@ LIB_FIELD* SCH_SEXPR_PARSER::parseProperty( std::unique_ptr<LIB_SYMBOL>& aSymbol
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid property value in\nfile: '%s'\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurOffset() );
CurLineNumber(),
CurOffset() );
THROW_IO_ERROR( error );
} }
// Empty property values are valid. // Empty property values are valid.
@ -1309,9 +1271,8 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid pin name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid pin name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
if( m_requiredVersion < 20210606 ) if( m_requiredVersion < 20210606 )
@ -1348,9 +1309,8 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid pin number in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid pin number" ), CurSource(), CurLine(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
pin->SetNumber( FromUTF8() ); pin->SetNumber( FromUTF8() );
@ -1386,9 +1346,8 @@ LIB_PIN* SCH_SEXPR_PARSER::parsePin()
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid alternate pin name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid alternate pin name" ), CurSource(), CurLine(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
alt.m_Name = FromUTF8(); alt.m_Name = FromUTF8();
@ -1543,7 +1502,6 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText()
T token; T token;
wxString tmp; wxString tmp;
wxString error;
std::unique_ptr<LIB_TEXT> text = std::make_unique<LIB_TEXT>( nullptr ); std::unique_ptr<LIB_TEXT> text = std::make_unique<LIB_TEXT>( nullptr );
text->SetUnit( m_unit ); text->SetUnit( m_unit );
@ -1552,9 +1510,8 @@ LIB_TEXT* SCH_SEXPR_PARSER::parseText()
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid text string in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid text string" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
text->SetText( FromUTF8() ); text->SetText( FromUTF8() );
@ -1600,9 +1557,8 @@ void SCH_SEXPR_PARSER::parsePAGE_INFO( PAGE_INFO& aPageInfo )
if( !aPageInfo.SetType( pageType ) ) if( !aPageInfo.SetType( pageType ) )
{ {
wxString err; THROW_PARSE_ERROR( _( "Invalid page type" ), CurSource(), CurLine(), CurLineNumber(),
err.Printf( _( "Page type \"%s\" is not valid " ), FromUTF8() ); CurOffset() );
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
if( pageType == PAGE_INFO::Custom ) if( pageType == PAGE_INFO::Custom )
@ -1729,9 +1685,8 @@ void SCH_SEXPR_PARSER::parseTITLE_BLOCK( TITLE_BLOCK& aTitleBlock )
break; break;
default: default:
wxString err; THROW_PARSE_ERROR( _( "Invalid title block comment number" ), CurSource(),
err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber ); CurLine(), CurLineNumber(), CurOffset() );
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
} }
break; break;
@ -1752,39 +1707,32 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent )
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( "Cannot parse " ) + GetTokenString( CurTok() ) +
wxT( " as a property token." ) ); wxT( " as a property token." ) );
wxString error;
wxString name;
wxString value;
T token = NextTok(); T token = NextTok();
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid property name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid property name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
name = FromUTF8(); wxString name = FromUTF8();
if( name.IsEmpty() ) if( name.IsEmpty() )
{ {
error.Printf( _( "Empty property name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Empty property name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
token = NextTok(); token = NextTok();
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid property value in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid property value" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
// Empty property values are valid. // Empty property values are valid.
value = FromUTF8(); wxString value = FromUTF8();
std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( wxDefaultPosition, -1, aParent, name ); std::unique_ptr<SCH_FIELD> field = std::make_unique<SCH_FIELD>( wxDefaultPosition, -1, aParent, name );
@ -1831,29 +1779,23 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet )
wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( "Cannot parse " ) + GetTokenString( CurTok() ) +
wxT( " as a sheet pin token." ) ); wxT( " as a sheet pin token." ) );
wxString error;
wxString name;
wxString shape;
T token = NextTok(); T token = NextTok();
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid sheet pin name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Invalid sheet pin name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
name = FromUTF8(); wxString name = FromUTF8();
if( name.IsEmpty() ) if( name.IsEmpty() )
{ {
error.Printf( _( "Empty sheet pin name in\nfile: \"%s\"\nline: %d\noffset: %d" ), THROW_PARSE_ERROR( _( "Empty sheet pin name" ), CurSource(), CurLine(), CurLineNumber(),
CurSource().c_str(), CurLineNumber(), CurOffset() ); CurOffset() );
THROW_IO_ERROR( error );
} }
std::unique_ptr<SCH_SHEET_PIN> sheetPin = std::make_unique<SCH_SHEET_PIN>( aSheet, wxPoint( 0, 0 ), name ); auto sheetPin = std::make_unique<SCH_SHEET_PIN>( aSheet, wxPoint( 0, 0 ), name );
token = NextTok(); token = NextTok();
@ -2272,7 +2214,6 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
T token; T token;
wxString tmp; wxString tmp;
wxString error;
wxString libName; wxString libName;
SCH_FIELD* field; SCH_FIELD* field;
std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>(); std::unique_ptr<SCH_SYMBOL> symbol = std::make_unique<SCH_SYMBOL>();
@ -2301,10 +2242,8 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
if( !IsSymbol( token ) ) if( !IsSymbol( token ) )
{ {
error.Printf( _( "Invalid symbol library name in\nfile: \"%s\"\n" THROW_PARSE_ERROR( _( "Invalid symbol library name" ), CurSource(), CurLine(),
"line: %d\noffset: %d" ), CurLineNumber(), CurOffset() );
CurSource().c_str(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
libName = FromUTF8(); libName = FromUTF8();
@ -2323,10 +2262,8 @@ SCH_SYMBOL* SCH_SEXPR_PARSER::parseSchematicSymbol()
if( libId.Parse( FromUTF8() ) >= 0 ) if( libId.Parse( FromUTF8() ) >= 0 )
{ {
error.Printf( _( "Invalid symbol library ID in\nfile: \"%s\"\nline: %d\n" THROW_PARSE_ERROR( _( "Invalid symbol library ID" ), CurSource(), CurLine(),
"offset: %d" ), CurLineNumber(), CurOffset() );
CurSource(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
} }
symbol->SetLibId( libId ); symbol->SetLibId( libId );

View File

@ -1518,13 +1518,13 @@ void SCH_SEXPR_PLUGIN_CACHE::Load()
{ {
if( !m_libFileName.FileExists() ) if( !m_libFileName.FileExists() )
{ {
THROW_IO_ERROR( wxString::Format( _( "Library file \"%s\" not found." ), THROW_IO_ERROR( wxString::Format( _( "Library file '%s' not found." ),
m_libFileName.GetFullPath() ) ); m_libFileName.GetFullPath() ) );
} }
wxCHECK_RET( m_libFileName.IsAbsolute(), wxCHECK_RET( m_libFileName.IsAbsolute(),
wxString::Format( "Cannot use relative file paths in sexpr plugin to " wxString::Format( "Cannot use relative file paths in sexpr plugin to "
"open library \"%s\".", m_libFileName.GetFullPath() ) ); "open library '%s'.", m_libFileName.GetFullPath() ) );
// The current locale must use period as the decimal point. // The current locale must use period as the decimal point.
wxCHECK2( wxLocale::GetInfo( wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER ) == ".", wxCHECK2( wxLocale::GetInfo( wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER ) == ".",

View File

@ -2607,7 +2607,7 @@ void SCH_LEGACY_PLUGIN_CACHE::Load()
{ {
if( !m_libFileName.FileExists() ) if( !m_libFileName.FileExists() )
{ {
THROW_IO_ERROR( wxString::Format( _( "Library file \"%s\" not found." ), THROW_IO_ERROR( wxString::Format( _( "Library file '%s' not found." ),
m_libFileName.GetFullPath() ) ); m_libFileName.GetFullPath() ) );
} }

View File

@ -504,8 +504,8 @@ bool SYMBOL_LIB_TABLE::LoadGlobalTable( SYMBOL_LIB_TABLE& aTable )
if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) ) if( !fn.DirExists() && !fn.Mkdir( 0x777, wxPATH_MKDIR_FULL ) )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( _( "Cannot create global library table path '%s'." ),
_( "Cannot create global library table path \"%s\"." ), fn.GetPath() ) ); fn.GetPath() ) );
} }
// Attempt to copy the default global file table from the KiCad // Attempt to copy the default global file table from the KiCad

View File

@ -455,8 +455,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadBoardStackup()
case LAYER_TYPE::ASSCOMPCOPP: case LAYER_TYPE::ASSCOMPCOPP:
case LAYER_TYPE::NOLAYER: case LAYER_TYPE::NOLAYER:
//Shouldn't be here if CPA file is correctly parsed and not corrupt //Shouldn't be here if CPA file is correctly parsed and not corrupt
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( _( "Unexpected layer '%s' in layer stack." ),
_( "Unexpected layer '%s' in layer stack." ), curLayer.Name ) ); curLayer.Name ) );
break; break;
case LAYER_TYPE::JUMPERLAYER: case LAYER_TYPE::JUMPERLAYER:
@ -1213,17 +1213,17 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadGroups()
{ {
if( m_groupMap.find( csGroup.ID ) == m_groupMap.end() ) if( m_groupMap.find( csGroup.ID ) == m_groupMap.end() )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( _( "Unable to find group ID %s in the group "
_( "The file appears to be corrupt. Unable to find group ID %s " "definitions." ),
"in the group definitions." ), csGroup.ID ) );
csGroup.ID ) );
} }
else if( m_groupMap.find( csGroup.ID ) == m_groupMap.end() ) else if( m_groupMap.find( csGroup.ID ) == m_groupMap.end() )
{ {
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( _( "Unable to find sub group %s in the group "
_( "The file appears to be corrupt. Unable to find sub group %s " "map (parent group ID=%s, Name=%s)." ),
"in the group map (parent group ID=%s, Name=%s)." ), csGroup.GroupID,
csGroup.GroupID, csGroup.ID, csGroup.Name ) ); csGroup.ID,
csGroup.Name ) );
} }
else else
{ {
@ -1535,18 +1535,19 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadAreas()
zone->SetDoNotAllowVias( area.NoVias ); zone->SetDoNotAllowVias( area.NoVias );
if( area.Placement ) if( area.Placement )
wxLogWarning( wxString::Format( {
_( "The CADSTAR area '%s' is marked as a placement area in CADSTAR. " wxLogWarning( wxString::Format( _( "The CADSTAR area '%s' is marked as a placement "
"Placement areas are not supported in KiCad. Only the supported " "area in CADSTAR. Placement areas are not "
"elements for the area were imported." ), "supported in KiCad. Only the supported elements "
area.Name ) ); "for the area were imported." ),
area.Name ) );
}
} }
else else
{ {
wxLogError( wxLogError( wxString::Format( _( "The CADSTAR area '%s' does not have a KiCad "
wxString::Format( _( "The CADSTAR area '%s' does not have a KiCad equivalent. " "equivalent. Pure Placement areas are not supported." ),
"Pure Placement areas are not supported." ), area.Name ) );
area.Name ) );
} }
//todo Process area.AreaHeight when KiCad supports 3D design rules //todo Process area.AreaHeight when KiCad supports 3D design rules
@ -1573,7 +1574,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadComponents()
{ {
THROW_IO_ERROR( wxString::Format( _( "Unable to find component '%s' in the library" THROW_IO_ERROR( wxString::Format( _( "Unable to find component '%s' in the library"
"(Symdef ID: '%s')" ), "(Symdef ID: '%s')" ),
comp.Name, comp.SymdefID ) ); comp.Name,
comp.SymdefID ) );
} }
FOOTPRINT* libFootprint = fpIter->second; FOOTPRINT* libFootprint = fpIter->second;

View File

@ -59,15 +59,14 @@ void CADSTAR_PCB_ARCHIVE_PARSER::Parse()
{ {
if( Header.Format.Type == wxT( "LIBRARY" ) ) if( Header.Format.Type == wxT( "LIBRARY" ) )
{ {
THROW_IO_ERROR( THROW_IO_ERROR( "The selected file is a CADSTAR library file (as opposed to a "
"The selected file is a CADSTAR Library file (as opposed to a Layout " "layout file). CADSTAR libraries cannot yet be imported into "
"file). CADSTAR libraries cannot yet be imported into KiCad." ); "KiCad." );
} }
else else
{ {
THROW_IO_ERROR( THROW_IO_ERROR( "The selected file is an unknown CADSTAR format so cannot be "
"The selected file is an unknown CADSTAR format so cannot be " "imported into KiCad." );
"imported into KiCad." );
} }
} }
} }

View File

@ -747,7 +747,7 @@ void LEGACY_PLUGIN::loadSHEET()
if( !page.SetType( wname ) ) if( !page.SetType( wname ) )
{ {
m_error.Printf( _( "Unknown sheet type \"%s\" on line:%d" ), m_error.Printf( _( "Unknown sheet type '%s' on line: %d." ),
wname.GetData(), wname.GetData(),
m_reader->LineNumber() ); m_reader->LineNumber() );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
@ -1427,9 +1427,8 @@ void LEGACY_PLUGIN::loadFOOTPRINT( FOOTPRINT* aFootprint )
} }
} }
wxString msg = wxString::Format( wxString msg = wxString::Format( _( "Missing '$EndMODULE' for MODULE '%s'." ),
_( "Missing '$EndMODULE' for MODULE \"%s\"" ), aFootprint->GetFPID().GetLibItemName().wx_str() ); aFootprint->GetFPID().GetLibItemName().wx_str() );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }
@ -1478,7 +1477,7 @@ void LEGACY_PLUGIN::loadPAD( FOOTPRINT* aFootprint )
case 'O': padshape = static_cast<int>( PAD_SHAPE::OVAL ); break; case 'O': padshape = static_cast<int>( PAD_SHAPE::OVAL ); break;
case 'T': padshape = static_cast<int>( PAD_SHAPE::TRAPEZOID ); break; case 'T': padshape = static_cast<int>( PAD_SHAPE::TRAPEZOID ); break;
default: default:
m_error.Printf( _( "Unknown padshape '%c=0x%02x' on line: %d of footprint: \"%s\"" ), m_error.Printf( _( "Unknown padshape '%c=0x%02x' on line: %d of footprint: '%s'." ),
padchar, padchar,
padchar, padchar,
m_reader->LineNumber(), m_reader->LineNumber(),
@ -1683,12 +1682,11 @@ void LEGACY_PLUGIN::loadFP_SHAPE( FOOTPRINT* aFootprint )
case 'A': shape = PCB_SHAPE_TYPE::ARC; break; case 'A': shape = PCB_SHAPE_TYPE::ARC; break;
case 'P': shape = PCB_SHAPE_TYPE::POLYGON; break; case 'P': shape = PCB_SHAPE_TYPE::POLYGON; break;
default: default:
m_error.Printf( _( "Unknown FP_SHAPE type:'%c=0x%02x' on line:%d of footprint:\"%s\"" ), m_error.Printf( _( "Unknown FP_SHAPE type:'%c=0x%02x' on line %d of footprint '%s'." ),
(unsigned char) line[1], (unsigned char) line[1],
(unsigned char) line[1], (unsigned char) line[1],
m_reader->LineNumber(), m_reader->LineNumber(),
aFootprint->GetFPID().GetLibItemName().wx_str() aFootprint->GetFPID().GetLibItemName().wx_str() );
);
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
} }

View File

@ -745,7 +745,7 @@ void PCB::ParseBoard( wxStatusBar* aStatusBar, wxXmlDocument* aXmlDoc, const wxS
m_layersStackup.Add( layerName ); m_layersStackup.Add( layerName );
if( m_layersStackup.size() > 32 ) if( m_layersStackup.size() > 32 )
THROW_IO_ERROR( _( "KiCad only supports 32 signal layers" ) ); THROW_IO_ERROR( _( "KiCad only supports 32 signal layers." ) );
} }
} }
} }

View File

@ -29,6 +29,7 @@
#include <xnode.h> #include <xnode.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/translation.h>
namespace PCAD2KICAD { namespace PCAD2KICAD {
@ -87,7 +88,7 @@ void PCB_VIA::Parse( XNODE* aNode,
lNode = FindNode( lNode, wxT( "library" ) ); lNode = FindNode( lNode, wxT( "library" ) );
if ( !lNode ) if ( !lNode )
THROW_IO_ERROR( wxT( "Unable to find library section" ) ); THROW_IO_ERROR( _( "Unable to find library section." ) );
lNode = FindNode( lNode, wxT( "viaStyleDef" ) ); lNode = FindNode( lNode, wxT( "viaStyleDef" ) );
@ -102,7 +103,7 @@ void PCB_VIA::Parse( XNODE* aNode,
} }
if ( !lNode ) if ( !lNode )
THROW_IO_ERROR( wxString::Format( wxT( "Unable to find viaStyleDef " ) + m_name.text ) ); THROW_IO_ERROR( wxString::Format( _( "Unable to find viaStyleDef %s." ), m_name.text ) );
if( lNode ) if( lNode )
{ {

View File

@ -220,9 +220,12 @@ PCB_VIA* SPECCTRA_DB::makeVIA( PADSTACK* aPadstack, const POINT& aPoint, int aNe
{ {
shape = (SHAPE*) (*aPadstack)[0]; shape = (SHAPE*) (*aPadstack)[0];
DSN_T type = shape->shape->Type(); DSN_T type = shape->shape->Type();
if( type != T_circle ) if( type != T_circle )
THROW_IO_ERROR( {
wxString::Format( _( "Unsupported via shape: %s" ), GetTokenString( type ) ) ); THROW_IO_ERROR( wxString::Format( _( "Unsupported via shape: %s." ),
GetTokenString( type ) ) );
}
CIRCLE* circle = (CIRCLE*) shape->shape; CIRCLE* circle = (CIRCLE*) shape->shape;
int viaDiam = scale( circle->diameter, m_routeResolution ); int viaDiam = scale( circle->diameter, m_routeResolution );
@ -495,8 +498,8 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard )
// wire_via to text and put that text into the exception. // wire_via to text and put that text into the exception.
wxString psid( FROM_UTF8( wire_via->GetPadstackId().c_str() ) ); wxString psid( FROM_UTF8( wire_via->GetPadstackId().c_str() ) );
THROW_IO_ERROR( wxString::Format( THROW_IO_ERROR( wxString::Format( _( "A wire_via refers to missing padstack '%s'." ),
_( "A wire_via references a missing padstack \"%s\"" ), psid ) ); psid ) );
} }
NETCLASSPTR netclass = aBoard->GetDesignSettings().GetNetClasses().GetDefault(); NETCLASSPTR netclass = aBoard->GetDesignSettings().GetNetClasses().GetDefault();