diff --git a/common/exceptions.cpp b/common/exceptions.cpp new file mode 100644 index 0000000000..bc90942bb9 --- /dev/null +++ b/common/exceptions.cpp @@ -0,0 +1,100 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2007-2016 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + + +#define THROWERS_WHERE _( "from %s : %s() line:%d" ) +#define PARSE_PROBLEM _( "%s in input/source\n'%s'\nline %d" ) + + +const wxString IO_ERROR::What() const +{ + return wxString( "IO_ERROR: " ) + Problem() + "\n\t" + Where(); +} + + +const wxString IO_ERROR::Where() const +{ + return where; +} + + +const wxString IO_ERROR::Problem() const +{ + return problem; +} + + + +void IO_ERROR::init( const wxString& aProblem, const char* aThrowersFile, const char* aThrowersFunction, int aThrowersLineNumber ) +{ + problem = aProblem; + + // The throwers filename is a full filename, depending on Kicad source location. + // a short filename will be printed (it is better for user, the full filename has no meaning). + wxString srcname = aThrowersFile; + + where.Printf( THROWERS_WHERE, srcname.AfterLast( '/' ).GetData(), + wxString( aThrowersFunction ).GetData(), aThrowersLineNumber ); +} + + +void PARSE_ERROR::init( const wxString& aProblem, const char* aThrowersFile, + const char* aThrowersFunction, int aThrowersLineNumber, + const wxString& aSource, + const char* aInputLine, + int aLineNumber, int aByteIndex ) +{ + problem.Printf( PARSE_PROBLEM, aProblem.GetData(), aSource.GetData(), aLineNumber, aByteIndex ); + + inputLine = aInputLine; + lineNumber = aLineNumber; + byteIndex = aByteIndex; + + // The throwers filename is a full filename, depending on Kicad source location. + // a short filename will be printed (it is better for user, the full filename has no meaning). + wxString srcname = aThrowersFile; + + where.Printf( THROWERS_WHERE, srcname.AfterLast( '/' ).GetData(), + wxString( aThrowersFunction ).GetData(), aThrowersLineNumber ); +} + + +FUTURE_FORMAT_ERROR::FUTURE_FORMAT_ERROR( const PARSE_ERROR& aParseError, const wxString& aRequiredVersion ) : + PARSE_ERROR(), requiredVersion( aRequiredVersion ) +{ + problem.Printf( _( + "KiCad was unable to open this file, as it was created with a more " + "recent version than the one you are running. To open it, you'll need " + "to upgrade KiCad to a more recent version.\n\n" + "Date of KiCad version required (or newer): %s\n\n" + "Full error text:\n%s" ), + requiredVersion, aParseError.Problem() ); + + lineNumber = aParseError.lineNumber; + byteIndex = aParseError.byteIndex; + inputLine = aParseError.inputLine; +} diff --git a/common/page_layout/page_layout_reader.cpp b/common/page_layout/page_layout_reader.cpp index 5d82eef7d7..d3b811f460 100644 --- a/common/page_layout/page_layout_reader.cpp +++ b/common/page_layout/page_layout_reader.cpp @@ -783,7 +783,7 @@ void WORKSHEET_LAYOUT::SetDefaultLayout() } catch( const IO_ERROR& ioe ) { - wxLogMessage( ioe.errorText ); + wxLogMessage( ioe.What() ); } } @@ -804,7 +804,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const char* aPageLayout, bool Append ) } catch( const IO_ERROR& ioe ) { - wxLogMessage( ioe.errorText ); + wxLogMessage( ioe.What() ); } } @@ -867,7 +867,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append } catch( const IO_ERROR& ioe ) { - wxLogMessage( ioe.errorText ); + wxLogMessage( ioe.What() ); } } diff --git a/common/richio.cpp b/common/richio.cpp index a1799f9bd9..200ca8f74e 100644 --- a/common/richio.cpp +++ b/common/richio.cpp @@ -98,39 +98,6 @@ std::string StrPrintf( const char* format, ... ) } -void IO_ERROR::init( const char* aThrowersFile, const char* aThrowersLoc, const wxString& aMsg ) -{ - // The throwers filename is a full filename, depending on Kicad source location. - // a short filename will be printed (it is better for user, the full filename has no meaning). - wxString srcname = wxString::FromUTF8( aThrowersFile ); - - errorText.Printf( IO_FORMAT, aMsg.GetData(), - srcname.AfterLast( '/' ).GetData(), - wxString::FromUTF8( aThrowersLoc ).GetData() ); -} - - -void PARSE_ERROR::init( const char* aThrowersFile, const char* aThrowersLoc, - const wxString& aMsg, const wxString& aSource, - const char* aInputLine, - int aLineNumber, int aByteIndex ) -{ - // save inpuLine, lineNumber, and offset for UI (.e.g. Sweet text editor) - inputLine = aInputLine; - lineNumber = aLineNumber; - byteIndex = aByteIndex; - - // The throwers filename is a full filename, depending on Kicad source location. - // a short filename will be printed (it is better for user, the full filename has no meaning). - wxString srcname = wxString::FromUTF8( aThrowersFile ); - - errorText.Printf( PARSE_FORMAT, aMsg.GetData(), aSource.GetData(), - aLineNumber, aByteIndex, - srcname.AfterLast( '/' ).GetData(), - wxString::FromUTF8( aThrowersLoc ).GetData() ); -} - - //----------------------------------------------------------- LINE_READER::LINE_READER( unsigned aMaxLineLength ) : diff --git a/common/single_top.cpp b/common/single_top.cpp index 70165014cb..2911ff2e12 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -60,9 +60,37 @@ KIWAY Kiway( &Pgm(), KFCTL_STANDALONE ); */ static struct PGM_SINGLE_TOP : public PGM_BASE { - bool OnPgmInit( wxApp* aWxApp ); // overload PGM_BASE virtual - void OnPgmExit(); // overload PGM_BASE virtual - void MacOpenFile( const wxString& aFileName ); // overload PGM_BASE virtual + bool OnPgmInit(); + + void OnPgmExit() + { + Kiway.OnKiwayEnd(); + + SaveCommonSettings(); + + // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl + // earlier than wxApp and earlier than static destruction would. + PGM_BASE::Destroy(); + } + + void MacOpenFile( const wxString& aFileName ) override + { + wxFileName filename( aFileName ); + + if( filename.FileExists() ) + { + #if 0 + // this pulls in EDA_DRAW_FRAME type info, which we don't want in + // the single_top link image. + KIWAY_PLAYER* frame = dynamic_cast( App().GetTopWindow() ); + #else + KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow(); + #endif + if( frame ) + frame->OpenProjectFiles( std::vector( 1, aFileName ) ); + } + } + } program; @@ -97,7 +125,7 @@ struct APP_SINGLE_TOP : public wxApp { try { - return Pgm().OnPgmInit( this ); + return program.OnPgmInit(); } catch( const std::exception& e ) { @@ -107,14 +135,14 @@ struct APP_SINGLE_TOP : public wxApp } catch( const IO_ERROR& ioe ) { - wxLogError( GetChars( ioe.errorText ) ); + wxLogError( GetChars( ioe.What() ) ); } catch(...) { wxLogError( wxT( "Unhandled exception of unknown type" ) ); } - Pgm().OnPgmExit(); + program.OnPgmExit(); return false; } @@ -123,7 +151,7 @@ struct APP_SINGLE_TOP : public wxApp { // Fixes segfault when wxPython scripting is enabled. #if defined( KICAD_SCRIPTING_WXPYTHON ) - Pgm().OnPgmExit(); + program.OnPgmExit(); #endif return wxApp::OnExit(); } @@ -144,7 +172,7 @@ struct APP_SINGLE_TOP : public wxApp } catch( const IO_ERROR& ioe ) { - wxLogError( GetChars( ioe.errorText ) ); + wxLogError( GetChars( ioe.What() ) ); } catch(...) { @@ -153,9 +181,8 @@ struct APP_SINGLE_TOP : public wxApp // Works properly when wxPython scripting is disabled. #if !defined( KICAD_SCRIPTING_WXPYTHON ) - Pgm().OnPgmExit(); + program.OnPgmExit(); #endif - return ret; } @@ -174,11 +201,9 @@ struct APP_SINGLE_TOP : public wxApp IMPLEMENT_APP( APP_SINGLE_TOP ); -bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) +bool PGM_SINGLE_TOP::OnPgmInit() { - // first thing: set m_wx_app - m_wx_app = aWxApp; - +#if defined(DEBUG) wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath(); if( !wxIsAbsolutePath( absoluteArgv0 ) ) @@ -186,11 +211,17 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) wxLogError( wxT( "No meaningful argv[0]" ) ); return false; } +#endif - if( !initPgm() ) + if( !InitPgm() ) return false; #if !defined(BUILD_KIWAY_DLL) + + // Only bitmap2component and pcb_calculator use this code currently, as they + // are not split to use single_top as a link image separate from a *.kiface. + // i.e. they are single part link images so don't need to load a *.kiface. + // Get the getter, it is statically linked into this binary image. KIFACE_GETTER_FUNC* getter = &KIFACE_GETTER; @@ -246,7 +277,6 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) // supporting a single argv[1]. if( !argv1.GetExt() ) argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) ); - #endif argv1.MakeAbsolute(); @@ -275,34 +305,3 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) return true; } - - -void PGM_SINGLE_TOP::OnPgmExit() -{ - Kiway.OnKiwayEnd(); - - saveCommonSettings(); - - // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl - // earlier than wxApp and earlier than static destruction would. - PGM_BASE::destroy(); -} - - -void PGM_SINGLE_TOP::MacOpenFile( const wxString& aFileName ) -{ - wxFileName filename( aFileName ); - - if( filename.FileExists() ) - { -#if 0 - // this pulls in EDA_DRAW_FRAME type info, which we don't want in - // the single_top link image. - KIWAY_PLAYER* frame = dynamic_cast( App().GetTopWindow() ); -#else - KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow(); -#endif - if( frame ) - frame->OpenProjectFiles( std::vector( 1, aFileName ) ); - } -} diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index cbb8e4ae00..d3b2f5344a 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -466,7 +466,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return NULL; } diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index a0c92e6541..512f61bb5d 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -181,7 +181,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) wxString msg = wxString::Format( _( "An error occurred attempting to load the global footprint library " "table:\n\n%s" ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); DisplayError( NULL, msg ); return false; diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 9b224d75a6..aa54eb6719 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -425,7 +425,7 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) wxString msg = wxString::Format( _( "Error occurred saving the global footprint library table:\n'%s'\n%s" ), GetChars( fileName ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } @@ -445,7 +445,7 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent ) wxString msg = wxString::Format( _( "Error occurred saving the project footprint library table:\n'%s'\n%s" ), GetChars( fileName ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } @@ -805,7 +805,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist ) } catch( const IO_ERROR& ioe ) { - wxString msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() ); + wxString msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.What().GetData() ); wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR ); return 1; } diff --git a/cvpcb/readwrite_dlgs.cpp b/cvpcb/readwrite_dlgs.cpp index bb53c2d667..f74c744341 100644 --- a/cvpcb/readwrite_dlgs.cpp +++ b/cvpcb/readwrite_dlgs.cpp @@ -245,7 +245,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist ) } catch( const IO_ERROR& ioe ) { - msg = ioe.errorText; + msg = ioe.What(); msg += wxT( "\n\n" ); msg += _( "First check your footprint library table entries." ); diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 0fe4ac368b..215477e150 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -1056,7 +1056,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR, boost::ba "Part library '%s' failed to load. Error:\n" "%s" ), GetChars( filename ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); THROW_IO_ERROR( msg ); @@ -1081,7 +1081,7 @@ void PART_LIBS::LoadAllLibraries( PROJECT* aProject ) throw( IO_ERROR, boost::ba wxString msg = wxString::Format( _( "Part library '%s' failed to load.\nError: %s" ), GetChars( cache_name ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); THROW_IO_ERROR( msg ); diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 9c8a160d62..f1f9e315e7 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -212,7 +212,7 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail ) } catch( const IO_ERROR& ioe ) { - DBG( printf( "%s: ioe:%s\n", __func__, TO_UTF8( ioe.errorText ) );) + DBG( printf( "%s: ioe:%s\n", __func__, TO_UTF8( ioe.What() ) );) } break; diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index cdbddc712c..2996d08ad6 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -140,7 +140,7 @@ void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event ) } catch( const IO_ERROR& ioe ) { - DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.errorText ) );) + DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );) return; } @@ -200,7 +200,7 @@ void SCH_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event ) } catch( const IO_ERROR& ioe ) { - DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.errorText ) );) + DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );) return; } @@ -663,7 +663,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) { // @todo show error msg DBG( printf( "templatefieldnames parsing error: '%s'\n", - TO_UTF8( e.errorText ) ); ) + TO_UTF8( e.What() ) ); ) } } } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index d2c151fd32..e9faa26067 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -121,7 +121,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, catch( const IO_ERROR& ioe ) { msg.Printf( _( "Error saving schematic file '%s'.\n%s" ), - GetChars( schematicFileName.GetFullPath() ), GetChars( ioe.errorText ) ); + GetChars( schematicFileName.GetFullPath() ), GetChars( ioe.What() ) ); DisplayError( this, msg ); msg.Printf( _( "Failed to save '%s'" ), GetChars( schematicFileName.GetFullPath() ) ); @@ -331,7 +331,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in { wxString msg; msg.Printf( _( "Error loading schematic file '%s'.\n%s" ), - GetChars( fullFileName ), GetChars( ioe.errorText ) ); + GetChars( fullFileName ), GetChars( ioe.What() ) ); DisplayError( this, msg ); msg.Printf( _( "Failed to load '%s'" ), GetChars( fullFileName ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_kicad.cpp b/eeschema/netlist_exporters/netlist_exporter_kicad.cpp index 75561819e3..b9dd37e3b7 100644 --- a/eeschema/netlist_exporters/netlist_exporter_kicad.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_kicad.cpp @@ -41,7 +41,7 @@ bool NETLIST_EXPORTER_KICAD::WriteNetlist( const wxString& aOutFileName, unsigne catch( const IO_ERROR& ioe ) { - DisplayError( NULL, ioe.errorText ); + DisplayError( NULL, ioe.What() ); return false; } diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index d79c354308..9762803632 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -89,7 +89,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ) } catch( IO_ERROR& e ) { - msg.Printf( wxT( "DXF Plotter exception: %s"), GetChars( e.errorText ) ); + msg.Printf( wxT( "DXF Plotter exception: %s"), GetChars( e.What() ) ); reporter.Report( msg, REPORTER::RPT_ERROR ); schframe->SetCurrentSheet( oldsheetpath ); schframe->GetCurrentSheet().UpdateAllScreenReferences(); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index 6248a32181..0c1846ef37 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -186,7 +186,7 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef ) } catch( IO_ERROR& e ) { - msg.Printf( wxT( "HPGL Plotter exception: %s"), GetChars( e.errorText ) ); + msg.Printf( wxT( "HPGL Plotter exception: %s"), GetChars( e.What() ) ); reporter.Report( msg, REPORTER::RPT_ERROR ); } diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index a168821a80..fc72b130ef 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -101,7 +101,7 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef ) catch( const IO_ERROR& e ) { // Cannot plot PDF file - msg.Printf( wxT( "PDF Plotter exception: %s" ), GetChars( e.errorText ) ); + msg.Printf( wxT( "PDF Plotter exception: %s" ), GetChars( e.What() ) ); reporter.Report( msg, REPORTER::RPT_ERROR ); restoreEnvironment( plotter, oldsheetpath ); diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index 86250727f1..e13550c19d 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -118,7 +118,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef ) } catch( IO_ERROR& e ) { - msg.Printf( wxT( "PS Plotter exception: %s"), GetChars( e.errorText ) ); + msg.Printf( wxT( "PS Plotter exception: %s"), GetChars( e.What() ) ); reporter.Report( msg, REPORTER::RPT_ERROR ); } } diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index d0835a76e9..e326b3d316 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -88,7 +88,7 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) catch( const IO_ERROR& e ) { // Cannot plot SVG file - msg.Printf( wxT( "SVG Plotter exception: %s" ), GetChars( e.errorText ) ); + msg.Printf( wxT( "SVG Plotter exception: %s" ), GetChars( e.What() ) ); reporter.Report( msg, REPORTER::RPT_ERROR ); break; } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index f6e07ccd75..ad33525205 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -117,7 +117,7 @@ SEARCH_STACK* PROJECT::SchSearchS() } catch( const IO_ERROR& ioe ) { - DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.errorText ) );) + DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );) } if( !!libDir ) @@ -182,7 +182,7 @@ PART_LIBS* PROJECT::SchLibs() } catch( const IO_ERROR& ioe ) { - DisplayError( NULL, ioe.errorText ); + DisplayError( NULL, ioe.What() ); } } diff --git a/eeschema/symbedit.cpp b/eeschema/symbedit.cpp index a36a4d211d..96d1045cbd 100644 --- a/eeschema/symbedit.cpp +++ b/eeschema/symbedit.cpp @@ -242,7 +242,7 @@ void LIB_EDIT_FRAME::SaveOneSymbol() } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return; } } diff --git a/include/ki_exception.h b/include/ki_exception.h new file mode 100644 index 0000000000..d9e9cd91e2 --- /dev/null +++ b/include/ki_exception.h @@ -0,0 +1,156 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2007-2016 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef KI_EXCEPTION_H_ +#define KI_EXCEPTION_H_ + +#include + + +/** + * @ingroup exception_types + * @{ + */ + + +/// macro which captures the "call site" values of __FILE_, __FUNCTION__ & __LINE__ +#define THROW_IO_ERROR( msg ) throw IO_ERROR( msg, __FILE__, __FUNCTION__, __LINE__ ) + + +/** + * Struct IO_ERROR + * is a class used to hold an error message and may be used when throwing exceptions + * containing meaningful error messages. + * @author Dick Hollenbeck + */ +class IO_ERROR // : std::exception +{ +public: + /** + * Constructor + * + * @param aProblem is Problem() text. + * + * @param aThrowersFile is the __FILE__ preprocessor macro but generated + * at the source file of thrower. + * + * @param aThrowersFunction is the function name at the throw site. + * @param aThrowersLineNumber, is the source code line number of the throw. + * + * Use macro THROW_IO_ERROR() to wrap a call to this constructor at the call site. + */ + IO_ERROR( const wxString& aProblem, const char* aThrowersFile, + const char* aThrowersFunction, int aThrowersLineNumber ) + { + init( aProblem, aThrowersFile, aThrowersFunction, aThrowersLineNumber ); + } + + IO_ERROR() {} + + void init( const wxString& aProblem, const char* aThrowersFile, + const char* aThrowersFunction, int aThrowersLineNumber ); + + virtual const wxString Problem() const; ///< what was the problem? + virtual const wxString Where() const; ///< where did the Problem() occur? + + virtual const wxString What() const; ///< A composite of Problem() and Where() + + virtual ~IO_ERROR() throw () {} + +protected: + wxString problem; + wxString where; +}; + + +#ifndef SWIG +/** + * Struct PARSE_ERROR + * contains a filename or source description, a problem input line, a line number, + * a byte offset, and an error message which contains the the caller's report and his + * call site information: CPP source file, function, and line number. + * @author Dick Hollenbeck + */ +struct PARSE_ERROR : public IO_ERROR +{ + int lineNumber; ///< at which line number, 1 based index. + int byteIndex; ///< at which byte offset within the line, 1 based index + + /// problem line of input [say, from a LINE_READER]. + /// this is brought up in original byte format rather than wxString form, incase + /// there was a problem with the encoding, in which case converting to wxString is + /// not reliable in this context. + std::string inputLine; + + /** + * Constructor + * which is normally called via the macro THROW_PARSE_ERROR so that + * __FILE__ and __FUNCTION__ and __LINE__ can be captured from the call site. + */ + PARSE_ERROR( const wxString& aProblem, const char* aThrowersFile, + const char* aThrowersFunction, int aThrowersLineNumber, + const wxString& aSource, + const char* aInputLine, + int aLineNumber, int aByteIndex ) : + IO_ERROR() + { + init( aProblem, aThrowersFile, aThrowersFunction, aThrowersLineNumber, + aSource, aInputLine, aLineNumber, aByteIndex ); + } + + void init( const wxString& aProblem, const char* aThrowersFile, + const char* aThrowersFunction, int aThrowersLineNumber, + const wxString& aSource, const char* aInputLine, + int aLineNumber, int aByteIndex ); + + ~PARSE_ERROR() throw () {} + +protected: + PARSE_ERROR(): IO_ERROR(), lineNumber( 0 ), byteIndex( 0 ) {} +}; + + +#define THROW_PARSE_ERROR( aProblem, aSource, aInputLine, aLineNumber, aByteIndex ) \ + throw PARSE_ERROR( aProblem, __FILE__, __FUNCTION__, __LINE__, aSource, aInputLine, aLineNumber, aByteIndex ) + + +/** + * Struct FUTURE_FORMAT_ERROR + * variant of PARSE_ERROR indicating that a syntax or related error was likely caused + * by a file generated by a newer version of KiCad than this. Can be used to generate + * more informative error messages. + */ +struct FUTURE_FORMAT_ERROR : public PARSE_ERROR +{ + wxString requiredVersion; ///< version or date of KiCad required to open file + + FUTURE_FORMAT_ERROR( const PARSE_ERROR& aParseError, const wxString& aRequiredVersion ); + ~FUTURE_FORMAT_ERROR() throw () {} +}; + +#endif // SWIG + +/** @} exception_types */ + +#endif // KI_EXCEPTION_H_ diff --git a/include/richio.h b/include/richio.h index f604b5fa03..3af7224938 100644 --- a/include/richio.h +++ b/include/richio.h @@ -37,6 +37,8 @@ #include #include +#include + /** * Function StrPrintf @@ -68,174 +70,6 @@ std::string StrPrintf( const char* format, ... ); -/** - * @ingroup exception_types - * @{ - */ - - -#define IO_FORMAT _( "IO_ERROR: %s\nfrom %s : %s" ) -#define PARSE_FORMAT _( "PARSE_ERROR: %s in input/source\n'%s'\nline %d offset %d\nfrom %s : %s" ) - -// references: -// http://stackoverflow.com/questions/2670816/how-can-i-use-the-compile-time-constant-line-in-a-string -#define STRINGIFY(x) #x -#define TOSTRING(x) STRINGIFY(x) - -// use one of the following __LOC__ defs, depending on whether your -// compiler supports __func__ or not, and how it handles __LINE__ -#define __LOC__ ((std::string(__FUNCTION__) + "() : line ") + TOSTRING(__LINE__)).c_str() -//#define __LOC__ TOSTRING(__LINE__) - -/// macro which captures the "call site" values of __FILE_ & __LOC__ -#define THROW_IO_ERROR( msg ) throw IO_ERROR( __FILE__, __LOC__, msg ) - -/** - * Struct IO_ERROR - * is a class used to hold an error message and may be used when throwing exceptions - * containing meaningful error messages. - * @author Dick Hollenbeck - */ -struct IO_ERROR // : std::exception -{ - wxString errorText; - - /** - * Constructor - * - * @param aThrowersFile is the __FILE__ preprocessor macro but generated - * at the source file of thrower. - * - * @param aThrowersLoc can be either a function name, such as __func__ - * or a stringified __LINE__ preprocessor macro but generated - * at the source function of the thrower, or concatonation. Use macro - * THROW_IO_ERROR() to wrap a call to this constructor at the call site. - * - * @param aMsg is error text that will be streamed through wxString.Printf() - * using the format string IO_FORMAT above. - */ - explicit IO_ERROR( const char* aThrowersFile, - const char* aThrowersLoc, - const wxString& aMsg ) - { - init( aThrowersFile, aThrowersLoc, aMsg ); - } - - explicit IO_ERROR( const char* aThrowersFile, - const char* aThrowersLoc, - const std::string& aMsg ) - { - init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg.c_str() ) ); - } - - explicit IO_ERROR( const char* aThrowersFile, - const char* aThrowersLoc, - const char* aMsg ) - { - init( aThrowersFile, aThrowersLoc, wxString::FromUTF8( aMsg ) ); - } - - /// handle the case where _() is passed as aMsg. - explicit IO_ERROR( const char* aThrowersFile, - const char* aThrowersLoc, - const wxChar* aMsg ) - { - init( aThrowersFile, aThrowersLoc, wxString( aMsg ) ); - } - - void init( const char* aThrowersFile, const char* aThrowersLoc, const wxString& aMsg ); - - IO_ERROR() {} - - // Destructor is virtual because PARSE_ERROR is derived from it and - // boost::ptr_vector lists consisting of both will need a virtual destructor. - virtual ~IO_ERROR() throw ( /*none*/ ){} -}; - - -/** - * Struct PARSE_ERROR - * contains a filename or source description, a problem input line, a line number, - * a byte offset, and an error message which contains the the caller's report and his - * call site information: CPP source file, function, and line number. - * @author Dick Hollenbeck - */ -struct PARSE_ERROR : public IO_ERROR -{ - // wxString errorText is still public from IO_ERROR - - int lineNumber; ///< at which line number, 1 based index. - int byteIndex; ///< at which byte offset within the line, 1 based index - - /// problem line of input [say, from a LINE_READER]. - /// this is brought up in original byte format rather than wxString form, incase - /// there was a problem with the encoding, in which case converting to wxString is - /// not reliable in this context. - std::string inputLine; - - /** - * Constructor - * which is normally called via the macro THROW_PARSE_ERROR so that - * __FILE__ and __LOC__ can be captured from the call site. - */ - PARSE_ERROR( const char* aThrowersFile, const char* aThrowersLoc, - const wxString& aMsg, const wxString& aSource, - const char* aInputLine, - int aLineNumber, int aByteIndex ) : - IO_ERROR() - { - init( aThrowersFile, aThrowersLoc, aMsg, aSource, aInputLine, aLineNumber, aByteIndex ); - } - - void init( const char* aThrowersFile, const char* aThrowersLoc, - const wxString& aMsg, const wxString& aSource, - const char* aInputLine, - int aLineNumber, int aByteIndex ); - - virtual ~PARSE_ERROR() throw ( /*none*/ ){} - -protected: - PARSE_ERROR(): IO_ERROR(), lineNumber( 0 ), byteIndex( 0 ) {} -}; - - -#define THROW_PARSE_ERROR( aMsg, aSource, aInputLine, aLineNumber, aByteIndex ) \ - throw PARSE_ERROR( __FILE__, __LOC__, aMsg, aSource, aInputLine, aLineNumber, aByteIndex ) - - -/** - * Struct FUTURE_FORMAT_ERROR - * variant of PARSE_ERROR indicating that a syntax or related error was likely caused - * by a file generated by a newer version of KiCad than this. Can be used to generate - * more informative error messages. - */ -struct FUTURE_FORMAT_ERROR : public PARSE_ERROR -{ - wxString requiredVersion; ///< version or date of KiCad required to open file - - FUTURE_FORMAT_ERROR( const PARSE_ERROR& aParseError, const wxString& aRequiredVersion ) : - PARSE_ERROR(), requiredVersion( aRequiredVersion ) - { - errorText.Printf( _( - "KiCad was unable to open this file, as it was created with a more " - "recent version than the one you are running. To open it, you'll need " - "to upgrade KiCad to a more recent version.\n\n" - "Date of KiCad version required (or newer): %s\n\n" - "Full error text:\n%s" ), - requiredVersion, aParseError.errorText ); - - lineNumber = aParseError.lineNumber; - byteIndex = aParseError.byteIndex; - inputLine = aParseError.inputLine; - } - - ~FUTURE_FORMAT_ERROR() throw () {} -}; - - -/** @} exception_types */ - - #define LINE_READER_LINE_DEFAULT_MAX 100000 #define LINE_READER_LINE_INITIAL_SIZE 5000 diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 777d9ddaec..8dc657fe2c 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -71,10 +71,9 @@ PGM_KICAD& PgmTop() } -bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) +bool PGM_KICAD::OnPgmInit() { - m_wx_app = aWxApp; // first thing. - +#if defined(DEBUG) wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath(); if( !wxIsAbsolutePath( absoluteArgv0 ) ) @@ -82,8 +81,9 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) wxLogError( wxT( "No meaningful argv[0]" ) ); return false; } +#endif - if( !initPgm() ) + if( !InitPgm() ) return false; m_bm.Init(); @@ -150,12 +150,12 @@ bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) prjloaded = true; // OnFileHistory() loads the project } } - else // there is no history + else // there is no history { - wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, - ProjectFileExtension ); + wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, + ProjectFileExtension ); - frame->SetProjectFileName( namelessProject.GetFullPath() ); + frame->SetProjectFileName( namelessProject.GetFullPath() ); } if( !prjloaded ) @@ -176,12 +176,12 @@ void PGM_KICAD::OnPgmExit() { Kiway.OnKiwayEnd(); - saveCommonSettings(); + SaveCommonSettings(); // write common settings to disk, and destroy everything in PGM_KICAD, // especially wxSingleInstanceCheckerImpl earlier than wxApp and earlier // than static destruction would. - destroy(); + Destroy(); } @@ -200,14 +200,14 @@ void PGM_KICAD::MacOpenFile( const wxString& aFileName ) } -void PGM_KICAD::destroy() +void PGM_KICAD::Destroy() { // unlike a normal destructor, this is designed to be called more // than once safely: m_bm.End(); - PGM_BASE::destroy(); + PGM_BASE::Destroy(); } @@ -234,25 +234,19 @@ struct APP_KICAD : public wxApp } #endif - bool OnInit() // overload wxApp virtual + bool OnInit() override { - // if( Kiways.OnStart( this ) ) - { - return Pgm().OnPgmInit( this ); - } - return false; + return program.OnPgmInit(); } - int OnExit() // overload wxApp virtual + int OnExit() override { - // Kiways.OnEnd(); - - Pgm().OnPgmExit(); + program.OnPgmExit(); return wxApp::OnExit(); } - int OnRun() // overload wxApp virtual + int OnRun() override { try { @@ -266,7 +260,7 @@ struct APP_KICAD : public wxApp } catch( const IO_ERROR& ioe ) { - wxLogError( GetChars( ioe.errorText ) ); + wxLogError( GetChars( ioe.What() ) ); } catch(...) { @@ -282,7 +276,7 @@ struct APP_KICAD : public wxApp * MacOSX requires it for file association. * @see http://wiki.wxwidgets.org/WxMac-specific_topics */ - void MacOpenFile( const wxString& aFileName ) // overload wxApp virtual + void MacOpenFile( const wxString& aFileName ) { Pgm().MacOpenFile( aFileName ); } @@ -298,21 +292,3 @@ PROJECT& Prj() return Kiway.Prj(); } - -#if 0 // there can be only one in C++ project manager. - -bool KIWAY_MGR::OnStart( wxApp* aProcess ) -{ - // The C++ project manager supports only one open PROJECT - // We should need no copy constructor for KIWAY to push a pointer. - m_kiways.push_back( new KIWAY() ); - - return true; -} - - -void KIWAY_MGR::OnEnd() -{ -} - -#endif diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp index 3a404f6812..fdf5ecdf59 100644 --- a/kicad/mainframe.cpp +++ b/kicad/mainframe.cpp @@ -306,7 +306,7 @@ void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName } catch( IO_ERROR err ) { - wxMessageBox( _( "Eeschema failed to load:\n" ) + err.errorText, + wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(), _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); return; } @@ -348,7 +348,7 @@ void KICAD_MANAGER_FRAME::OnRunSchLibEditor( wxCommandEvent& event ) } catch( IO_ERROR err ) { - wxMessageBox( _( "Component library editor failed to load:\n" ) + err.errorText, + wxMessageBox( _( "Component library editor failed to load:\n" ) + err.What(), _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); return; } @@ -375,7 +375,7 @@ void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName ) } catch( IO_ERROR err ) { - wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.errorText, _( "KiCad Error" ), + wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); return; } @@ -421,7 +421,7 @@ void KICAD_MANAGER_FRAME::OnRunPcbFpEditor( wxCommandEvent& event ) } catch( IO_ERROR err ) { - wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.errorText, + wxMessageBox( _( "Footprint library editor failed to load:\n" ) + err.What(), _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); return; } diff --git a/pagelayout_editor/page_layout_writer.cpp b/pagelayout_editor/page_layout_writer.cpp index 07d3dda5af..ecc242ad4f 100644 --- a/pagelayout_editor/page_layout_writer.cpp +++ b/pagelayout_editor/page_layout_writer.cpp @@ -102,7 +102,7 @@ public: } catch( const IO_ERROR& ioe ) { - wxMessageBox( ioe.errorText, _( "Error writing page layout descr file" ) ); + wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) ); } } @@ -130,7 +130,7 @@ public: } catch( const IO_ERROR& ioe ) { - wxMessageBox( ioe.errorText, _( "Error writing page layout descr file" ) ); + wxMessageBox( ioe.What(), _( "Error writing page layout descr file" ) ); } } diff --git a/pcb_calculator/datafile_read_write.cpp b/pcb_calculator/datafile_read_write.cpp index 00b09dfa3e..fda6a9ff7d 100644 --- a/pcb_calculator/datafile_read_write.cpp +++ b/pcb_calculator/datafile_read_write.cpp @@ -70,7 +70,7 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile() { delete datafile; - wxString msg = ioe.errorText; + wxString msg = ioe.What(); msg += wxChar('\n'); msg += _("Data file error."); diff --git a/pcbnew/append_board_to_current.cpp b/pcbnew/append_board_to_current.cpp index aff84e1a57..48f4eb3346 100644 --- a/pcbnew/append_board_to_current.cpp +++ b/pcbnew/append_board_to_current.cpp @@ -90,7 +90,7 @@ bool PCB_EDIT_FRAME::AppendBoardFile( const wxString& aFullFileName, int aCtl ) wxString msg = wxString::Format( _( "Error loading board.\n%s" ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); DisplayError( this, msg ); diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 0dbaa33ae1..bbe77563aa 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -156,7 +156,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs() } catch( const IO_ERROR& ioe ) { - DisplayError( NULL, ioe.errorText ); + DisplayError( NULL, ioe.What() ); } } diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 1f3b4d6f83..cb9aae43b1 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -250,7 +250,7 @@ protected: } catch( PARSE_ERROR& pe ) { - DisplayError( NULL, pe.errorText ); + DisplayError( NULL, pe.What() ); parsed = false; } diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index cd9a9e83c7..bbde033e3a 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -429,7 +429,7 @@ bool DIALOG_NETLIST::verifyFootprints( const wxString& aNetlistFilename, } catch( const IO_ERROR& ioe ) { - msg.Printf( _( "Error loading netlist file:\n%s" ), ioe.errorText.GetData() ); + msg.Printf( _( "Error loading netlist file:\n%s" ), ioe.What().GetData() ); wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR ); return false; } diff --git a/pcbnew/dialogs/dialog_update_pcb.cpp b/pcbnew/dialogs/dialog_update_pcb.cpp index ff35ec52cd..9e46dc82e2 100644 --- a/pcbnew/dialogs/dialog_update_pcb.cpp +++ b/pcbnew/dialogs/dialog_update_pcb.cpp @@ -61,7 +61,7 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun ) reporter.Report( _( "Failed to load one or more footprints. Please add the missing libraries in PCBNew configuration. " "The PCB will not update completely." ), REPORTER::RPT_ERROR ); - reporter.Report( error.errorText, REPORTER::RPT_INFO ); + reporter.Report( error.What(), REPORTER::RPT_INFO ); } BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() ); diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp index 47afc5ab11..348da391e5 100644 --- a/pcbnew/dialogs/wizard_add_fplib.cpp +++ b/pcbnew/dialogs/wizard_add_fplib.cpp @@ -668,7 +668,7 @@ bool WIZARD_FPLIB_TABLE::downloadGithubLibsFromList( wxArrayString& aUrlList, { if( aErrorMessage ) aErrorMessage->Printf( _( "Error:\n'%s'\nwhile downloading library:\n'%s'" ), - GetChars( ioe.errorText ), GetChars( libsrc_name ) ); + GetChars( ioe.What() ), GetChars( libsrc_name ) ); return false; } } diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index da14472b36..dffceab5ce 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -611,7 +611,7 @@ bool PCB_EDIT_FRAME::Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, catch( const IO_ERROR& ioe ) { wxString msg; - msg << _( "IDF Export Failed:\n" ) << ioe.errorText; + msg << _( "IDF Export Failed:\n" ) << ioe.What(); wxMessageBox( msg ); ok = false; diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index a560a2f3f9..4790a57855 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -522,7 +522,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in { wxString msg = wxString::Format( _( "Error loading board.\n%s" ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); DisplayError( this, msg ); return false; @@ -727,7 +727,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF wxString msg = wxString::Format( _( "Error saving board file '%s'.\n%s" ), GetChars( pcbFileName.GetFullPath() ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); DisplayError( this, msg ); @@ -807,7 +807,7 @@ bool PCB_EDIT_FRAME::SavePcbCopy( const wxString& aFileName ) wxString msg = wxString::Format( _( "Error saving board file '%s'.\n%s" ), GetChars( pcbFileName.GetFullPath() ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); DisplayError( this, msg ); diff --git a/pcbnew/github/github_getliblist.cpp b/pcbnew/github/github_getliblist.cpp index 07b3fb1637..eec1a87138 100644 --- a/pcbnew/github/github_getliblist.cpp +++ b/pcbnew/github/github_getliblist.cpp @@ -236,7 +236,7 @@ bool GITHUB_GETLIBLIST::remoteGetJSON( const std::string& aFullURLCommand, wxStr std::string msg = StrPrintf( fmt.c_str(), aFullURLCommand.c_str(), - TO_UTF8( ioe.errorText ) ); + TO_UTF8( ioe.What() ) ); *aMsgError = FROM_UTF8( msg.c_str() ); } diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index e43c2fbb0b..31055f6ed8 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -548,7 +548,7 @@ void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL ) throw( IO_ERROR ) errorcmd, zip_url.c_str(), TO_UTF8( aRepoURL ), - TO_UTF8( ioe.errorText ) + TO_UTF8( ioe.What() ) ); THROW_IO_ERROR( msg ); @@ -587,7 +587,7 @@ int main( int argc, char** argv ) } catch( const IO_ERROR& ioe ) { - printf( "%s\n", TO_UTF8(ioe.errorText) ); + printf( "%s\n", TO_UTF8(ioe.What()) ); } UNINIT_LOGGER(); diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index e19fc4c88b..4ebc6db2ec 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -120,7 +120,7 @@ static wxFileName prompt_for_module( wxWindow* aParent, const wxString& aLastPat if( dlg.ShowModal() == wxID_CANCEL ) return wxFileName(); - + lastFilterIndex = dlg.GetFilterIndex(); return wxFileName( dlg.GetPath() ); @@ -309,7 +309,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module() } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return NULL; } @@ -397,7 +397,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule ) } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return; } @@ -426,7 +426,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath ) } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return false; } return true; @@ -494,7 +494,7 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary() } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return wxEmptyString; } @@ -549,7 +549,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary() } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return false; } @@ -595,7 +595,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib ) } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); } } else @@ -619,7 +619,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib ) } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); } } } @@ -722,7 +722,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( const wxString& aLibrary, } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return false; } diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index f40fa72afb..d081782239 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -234,7 +234,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, catch( const IO_ERROR& ioe ) { wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ), - fpid.Format().c_str(), GetChars( ioe.errorText ) ); + fpid.Format().c_str(), GetChars( ioe.What() ) ); } if( !module && allowWildSeach ) // Search with wild card @@ -264,7 +264,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary, catch( const IO_ERROR& ioe ) { wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ), - fpid.Format().c_str(), GetChars( ioe.errorText ) ); + fpid.Format().c_str(), GetChars( ioe.What() ) ); } } } @@ -321,7 +321,7 @@ MODULE* PCB_BASE_FRAME::LoadFootprint( const FPID& aFootprintId ) catch( const IO_ERROR& ioe ) { wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ), - aFootprintId.Format().c_str(), GetChars( ioe.errorText ) ); + aFootprintId.Format().c_str(), GetChars( ioe.What() ) ); } return module; @@ -564,7 +564,7 @@ void FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs( wxCommandEvent& aEvent ) } catch( const IO_ERROR& ioe ) { - DisplayError( this, ioe.errorText ); + DisplayError( this, ioe.What() ); return; } diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 055fac4049..5c4d6a0aa2 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -882,7 +882,7 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event ) wxString msg = wxString::Format( _( "Error occurred saving the global footprint library " "table:\n\n%s" ), - GetChars( ioe.errorText.GetData() ) + GetChars( ioe.What().GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } @@ -902,7 +902,7 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event ) wxString msg = wxString::Format( _( "Error occurred saving project specific footprint library " "table:\n\n%s" ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 2cd9f6143f..f00948accf 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -463,7 +463,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) _( "Could not load footprint \"%s\" from library \"%s\".\n\nError %s." ), GetChars( getCurFootprintName() ), GetChars( getCurNickname() ), - GetChars( ioe.errorText ) ); + GetChars( ioe.What() ) ); DisplayError( this, msg ); } diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index c83c1994ab..295e8d3188 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -96,7 +96,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName, } catch( const IO_ERROR& ioe ) { - msg.Printf( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() ); + msg.Printf( _( "Error loading netlist.\n%s" ), ioe.What().GetData() ); wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR ); return; } diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index dc6eb63862..d8d904d31e 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -349,7 +349,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) wxString msg = wxString::Format( _( "An error occurred attempting to load the global footprint library " "table:\n\n%s" ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); DisplayError( NULL, msg ); return false; diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 9385e6d92b..0ce9a724b7 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -137,7 +137,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) wxString msg = wxString::Format( _( "Error occurred saving the global footprint library " "table:\n\n%s" ), - GetChars( ioe.errorText.GetData() ) + GetChars( ioe.What().GetData() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } @@ -159,7 +159,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) wxString msg = wxString::Format( _( "Error occurred saving project specific footprint library " "table:\n\n%s" ), - GetChars( ioe.errorText ) + GetChars( ioe.What() ) ); wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR ); } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 50dd0323ec..6df8c626c0 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -185,7 +185,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename ) ok = false; // copy the error string to safe place, ioe is in this scope only. - errorText = ioe.errorText; + errorText = ioe.What(); } // done assuredly, even if an exception was thrown and caught. @@ -1397,7 +1397,7 @@ bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard, // from global bounding box success = false; if( aErrorText ) - *aErrorText = ioe.errorText; + *aErrorText = ioe.What(); EDA_RECT bbbox = aBoard->ComputeBoundingBox( true ); diff --git a/pcbnew/specctra_import.cpp b/pcbnew/specctra_import.cpp index 39d7948f81..2326eb17ad 100644 --- a/pcbnew/specctra_import.cpp +++ b/pcbnew/specctra_import.cpp @@ -103,7 +103,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) } catch( const IO_ERROR& ioe ) { - wxString msg = ioe.errorText; + wxString msg = ioe.What(); msg += '\n'; msg += _("BOARD may be corrupted, do not save it."); msg += '\n'; diff --git a/pcbnew/specctra_test.cpp b/pcbnew/specctra_test.cpp index 3a6cc0b47a..0e0733cb45 100644 --- a/pcbnew/specctra_test.cpp +++ b/pcbnew/specctra_test.cpp @@ -65,7 +65,7 @@ int main( int argc, char** argv ) } catch( const IO_ERROR& ioe ) { - fprintf( stderr, "%s\n", TO_UTF8(ioe.errorText) ); + fprintf( stderr, "%s\n", TO_UTF8(ioe.What()) ); failed = true; } diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index ecc7e4fd79..2b7f90f186 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -821,7 +821,7 @@ int PCBNEW_CONTROL::AppendBoard( const TOOL_EVENT& aEvent ) } catch( const IO_ERROR& ioe ) { - wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.errorText )); + wxString msg = wxString::Format( _( "Error loading board.\n%s" ), GetChars( ioe.What() )); DisplayError( editFrame, msg ); return 0;