2016-09-14 22:36:45 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
2017-01-27 12:27:53 +00:00
|
|
|
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-09-14 22:36:45 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-06-07 22:20:47 +00:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/translation.h>
|
2016-09-14 22:36:45 +00:00
|
|
|
#include <ki_exception.h>
|
|
|
|
|
|
|
|
|
|
|
|
const wxString IO_ERROR::What() const
|
|
|
|
{
|
2016-12-29 17:21:57 +00:00
|
|
|
#ifdef DEBUG
|
2023-01-17 12:42:30 +00:00
|
|
|
return wxString( wxS( "IO_ERROR: " ) ) + Problem() + wxS("\n\n" ) + Where();
|
2016-12-29 17:21:57 +00:00
|
|
|
#else
|
|
|
|
return Problem();
|
|
|
|
#endif
|
2016-09-14 22:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString IO_ERROR::Where() const
|
|
|
|
{
|
|
|
|
return where;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxString IO_ERROR::Problem() const
|
|
|
|
{
|
|
|
|
return problem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-28 17:49:04 +00:00
|
|
|
void IO_ERROR::init( const wxString& aProblem, const char* aThrowersFile,
|
|
|
|
const char* aThrowersFunction, int aThrowersLineNumber )
|
2016-09-14 22:36:45 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
2021-06-27 23:26:54 +00:00
|
|
|
where.Printf( _( "from %s : %s() line %d" ),
|
|
|
|
srcname.AfterLast( '/' ),
|
|
|
|
wxString( aThrowersFunction ),
|
|
|
|
aThrowersLineNumber );
|
2016-09-14 22:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PARSE_ERROR::init( const wxString& aProblem, const char* aThrowersFile,
|
2020-07-28 17:49:04 +00:00
|
|
|
const char* aThrowersFunction, int aThrowersLineNumber,
|
|
|
|
const wxString& aSource, const char* aInputLine, int aLineNumber,
|
|
|
|
int aByteIndex )
|
2016-09-14 22:36:45 +00:00
|
|
|
{
|
2020-10-15 23:38:33 +00:00
|
|
|
parseProblem = aProblem;
|
|
|
|
|
2021-06-27 23:26:54 +00:00
|
|
|
problem.Printf( _( "%s in '%s', line %d, offset %d." ),
|
2020-07-28 17:49:04 +00:00
|
|
|
aProblem,
|
|
|
|
aSource,
|
|
|
|
aLineNumber,
|
|
|
|
aByteIndex );
|
2016-09-14 22:36:45 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-06-30 15:06:07 +00:00
|
|
|
where.Printf( _( "from %s : %s() line:%d" ),
|
|
|
|
srcname.AfterLast( '/' ),
|
|
|
|
wxString( aThrowersFunction ),
|
|
|
|
aThrowersLineNumber );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-19 14:02:52 +00:00
|
|
|
void FUTURE_FORMAT_ERROR::init( const wxString& aRequiredVersion,
|
|
|
|
const wxString& aRequiredGenerator )
|
2021-06-30 15:06:07 +00:00
|
|
|
{
|
|
|
|
requiredVersion = aRequiredVersion;
|
2023-11-19 14:02:52 +00:00
|
|
|
requiredGenerator = aRequiredGenerator;
|
2021-06-30 15:06:07 +00:00
|
|
|
|
2023-11-19 14:02:52 +00:00
|
|
|
if( requiredGenerator.IsEmpty() )
|
|
|
|
{
|
|
|
|
problem.Printf( _( "KiCad was unable to open this file because it was created with a more "
|
|
|
|
"recent version than the one you are running.\n\n"
|
|
|
|
"To open it you will need to upgrade KiCad to a version dated %s or "
|
|
|
|
"later." ),
|
|
|
|
aRequiredVersion );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
problem.Printf( _( "KiCad was unable to open this file because it was created with a more "
|
|
|
|
"recent version than the one you are running.\n\n"
|
|
|
|
"To open it you will need to upgrade KiCad to version %s or "
|
|
|
|
"later (file format dated %s or later)." ),
|
|
|
|
aRequiredGenerator, aRequiredVersion );
|
|
|
|
}
|
2021-06-30 15:06:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-19 14:02:52 +00:00
|
|
|
FUTURE_FORMAT_ERROR::FUTURE_FORMAT_ERROR( const wxString& aRequiredVersion,
|
|
|
|
const wxString& aRequiredGenerator ) :
|
2021-06-30 15:06:07 +00:00
|
|
|
PARSE_ERROR()
|
|
|
|
{
|
2023-11-19 14:02:52 +00:00
|
|
|
init( aRequiredVersion, aRequiredGenerator );
|
2021-06-30 15:06:07 +00:00
|
|
|
|
|
|
|
lineNumber = 0;
|
|
|
|
byteIndex = 0;
|
2016-09-14 22:36:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-30 16:07:11 +00:00
|
|
|
FUTURE_FORMAT_ERROR::FUTURE_FORMAT_ERROR( const PARSE_ERROR& aParseError,
|
2023-11-19 14:02:52 +00:00
|
|
|
const wxString& aRequiredVersion,
|
|
|
|
const wxString& aRequiredGenerator ) :
|
2021-06-30 15:06:07 +00:00
|
|
|
PARSE_ERROR()
|
2016-09-14 22:36:45 +00:00
|
|
|
{
|
2023-05-30 23:45:07 +00:00
|
|
|
if( const FUTURE_FORMAT_ERROR* ffe = dynamic_cast<const FUTURE_FORMAT_ERROR*>( &aParseError ) )
|
|
|
|
{
|
|
|
|
requiredVersion = ffe->requiredVersion;
|
2023-11-19 14:02:52 +00:00
|
|
|
requiredGenerator = ffe->requiredGenerator;
|
2023-05-30 23:45:07 +00:00
|
|
|
problem = ffe->Problem();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-11-19 14:02:52 +00:00
|
|
|
init( aRequiredVersion, aRequiredGenerator );
|
2023-05-30 23:45:07 +00:00
|
|
|
|
|
|
|
if( !aParseError.Problem().IsEmpty() )
|
|
|
|
problem += wxS( "\n\n" ) + _( "Full error text:" ) + wxS( "\n" ) + aParseError.Problem();
|
|
|
|
}
|
2016-09-14 22:36:45 +00:00
|
|
|
|
|
|
|
lineNumber = aParseError.lineNumber;
|
|
|
|
byteIndex = aParseError.byteIndex;
|
|
|
|
inputLine = aParseError.inputLine;
|
|
|
|
}
|