Split IO_ERROR out of richio.* and store Problem() and Where() separately
This commit is contained in:
parent
9761c881e2
commit
9ad49dc2d1
|
@ -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 <dick@softplc.com>
|
||||
* 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 <wx/wx.h>
|
||||
#include <ki_exception.h>
|
||||
|
||||
|
||||
#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;
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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::LINE_READER( unsigned aMaxLineLength ) :
|
||||
|
|
|
@ -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<KIWAY_PLAYER*>( App().GetTopWindow() );
|
||||
#else
|
||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
|
||||
#endif
|
||||
if( frame )
|
||||
frame->OpenProjectFiles( std::vector<wxString>( 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<KIWAY_PLAYER*>( App().GetTopWindow() );
|
||||
#else
|
||||
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
|
||||
#endif
|
||||
if( frame )
|
||||
frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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." );
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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() ) ); )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<wxString>& 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 ) );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this, ioe.errorText );
|
||||
DisplayError( this, ioe.What() );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <dick@softplc.com>
|
||||
* 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 <wx/string.h>
|
||||
|
||||
|
||||
/**
|
||||
* @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_
|
170
include/richio.h
170
include/richio.h
|
@ -37,6 +37,8 @@
|
|||
#include <wx/wx.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ki_exception.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.");
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs()
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( NULL, ioe.errorText );
|
||||
DisplayError( NULL, ioe.What() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ protected:
|
|||
}
|
||||
catch( PARSE_ERROR& pe )
|
||||
{
|
||||
DisplayError( NULL, pe.errorText );
|
||||
DisplayError( NULL, pe.What() );
|
||||
parsed = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -522,7 +522,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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 );
|
||||
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue