2015-10-15 09:50:25 +00:00
|
|
|
/*
|
2016-11-18 23:13:20 +00:00
|
|
|
This file is part of solidity.
|
2015-10-15 09:50:25 +00:00
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is free software: you can redistribute it and/or modify
|
2015-10-15 09:50:25 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2016-11-18 23:13:20 +00:00
|
|
|
solidity is distributed in the hope that it will be useful,
|
2015-10-15 09:50:25 +00:00
|
|
|
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
|
2016-11-18 23:13:20 +00:00
|
|
|
along with solidity. If not, see <http://www.gnu.org/licenses/>.
|
2015-10-15 09:50:25 +00:00
|
|
|
*/
|
2020-07-17 14:54:12 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0
|
2015-10-15 09:50:25 +00:00
|
|
|
/**
|
2015-10-15 12:36:23 +00:00
|
|
|
* @author Liana <liana@ethdev.com>
|
2015-10-15 09:50:25 +00:00
|
|
|
* @date 2015
|
|
|
|
* Solidity exception hierarchy.
|
|
|
|
*/
|
|
|
|
|
2018-11-14 13:59:30 +00:00
|
|
|
#include <liblangutil/Exceptions.h>
|
2015-10-15 09:50:25 +00:00
|
|
|
|
2021-09-24 04:25:20 +00:00
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
|
|
#include <boost/algorithm/string/trim.hpp>
|
|
|
|
|
2019-12-11 16:31:36 +00:00
|
|
|
using namespace solidity;
|
|
|
|
using namespace solidity::langutil;
|
2015-10-15 09:50:25 +00:00
|
|
|
|
2023-09-29 20:07:44 +00:00
|
|
|
std::map<Error::Type, std::string> const Error::m_errorTypeNames = {
|
|
|
|
{Error::Type::IOError, "IOError"},
|
|
|
|
{Error::Type::FatalError, "FatalError"},
|
|
|
|
{Error::Type::JSONError, "JSONError"},
|
|
|
|
{Error::Type::InternalCompilerError, "InternalCompilerError"},
|
|
|
|
{Error::Type::CompilerError, "CompilerError"},
|
|
|
|
{Error::Type::Exception, "Exception"},
|
|
|
|
{Error::Type::CodeGenerationError, "CodeGenerationError"},
|
|
|
|
{Error::Type::DeclarationError, "DeclarationError"},
|
|
|
|
{Error::Type::DocstringParsingError, "DocstringParsingError"},
|
|
|
|
{Error::Type::ParserError, "ParserError"},
|
|
|
|
{Error::Type::SyntaxError, "SyntaxError"},
|
|
|
|
{Error::Type::TypeError, "TypeError"},
|
|
|
|
{Error::Type::UnimplementedFeatureError, "UnimplementedFeatureError"},
|
|
|
|
{Error::Type::YulException, "YulException"},
|
|
|
|
{Error::Type::SMTLogicException, "SMTLogicException"},
|
|
|
|
{Error::Type::Warning, "Warning"},
|
|
|
|
{Error::Type::Info, "Info"},
|
|
|
|
};
|
|
|
|
|
2020-10-31 02:40:41 +00:00
|
|
|
Error::Error(
|
|
|
|
ErrorId _errorId, Error::Type _type,
|
|
|
|
std::string const& _description,
|
|
|
|
SourceLocation const& _location,
|
|
|
|
SecondarySourceLocation const& _secondaryLocation
|
|
|
|
):
|
2020-05-28 02:32:46 +00:00
|
|
|
m_errorId(_errorId),
|
2017-03-03 17:44:28 +00:00
|
|
|
m_type(_type)
|
2015-10-15 09:50:25 +00:00
|
|
|
{
|
2020-02-03 07:04:21 +00:00
|
|
|
if (_location.isValid())
|
2017-03-03 17:44:28 +00:00
|
|
|
*this << errinfo_sourceLocation(_location);
|
2020-10-31 02:40:41 +00:00
|
|
|
if (!_secondaryLocation.infos.empty())
|
|
|
|
*this << errinfo_secondarySourceLocation(_secondaryLocation);
|
2017-03-03 17:44:28 +00:00
|
|
|
if (!_description.empty())
|
2019-12-11 16:31:36 +00:00
|
|
|
*this << util::errinfo_comment(_description);
|
2015-10-15 09:50:25 +00:00
|
|
|
}
|
2021-09-24 04:25:20 +00:00
|
|
|
|
2021-12-01 11:30:36 +00:00
|
|
|
SourceLocation const* Error::sourceLocation() const noexcept
|
|
|
|
{
|
|
|
|
return boost::get_error_info<errinfo_sourceLocation>(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
SecondarySourceLocation const* Error::secondarySourceLocation() const noexcept
|
|
|
|
{
|
|
|
|
return boost::get_error_info<errinfo_secondarySourceLocation>(*this);
|
|
|
|
}
|