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
|
|
|
*/
|
|
|
|
/**
|
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
|
|
|
|
2017-02-24 18:31:20 +00:00
|
|
|
using namespace std;
|
2019-12-11 16:31:36 +00:00
|
|
|
using namespace solidity;
|
|
|
|
using namespace solidity::langutil;
|
2015-10-15 09:50:25 +00:00
|
|
|
|
2017-03-03 17:44:28 +00:00
|
|
|
Error::Error(Type _type, SourceLocation const& _location, string const& _description):
|
|
|
|
m_type(_type)
|
2015-10-15 09:50:25 +00:00
|
|
|
{
|
2019-11-11 16:09:59 +00:00
|
|
|
switch (m_type)
|
2015-10-15 09:50:25 +00:00
|
|
|
{
|
2015-10-21 14:43:31 +00:00
|
|
|
case Type::DeclarationError:
|
2017-04-24 10:25:33 +00:00
|
|
|
m_typeName = "DeclarationError";
|
2015-10-21 14:43:31 +00:00
|
|
|
break;
|
|
|
|
case Type::DocstringParsingError:
|
2017-04-24 10:25:33 +00:00
|
|
|
m_typeName = "DocstringParsingError";
|
2015-10-21 14:43:31 +00:00
|
|
|
break;
|
|
|
|
case Type::ParserError:
|
2017-04-24 10:25:33 +00:00
|
|
|
m_typeName = "ParserError";
|
2015-10-21 14:43:31 +00:00
|
|
|
break;
|
2016-01-14 01:58:09 +00:00
|
|
|
case Type::SyntaxError:
|
2017-04-24 10:25:33 +00:00
|
|
|
m_typeName = "SyntaxError";
|
2016-01-14 01:58:09 +00:00
|
|
|
break;
|
2015-10-21 14:43:31 +00:00
|
|
|
case Type::TypeError:
|
2017-04-24 10:25:33 +00:00
|
|
|
m_typeName = "TypeError";
|
2015-10-21 14:43:31 +00:00
|
|
|
break;
|
|
|
|
case Type::Warning:
|
|
|
|
m_typeName = "Warning";
|
|
|
|
break;
|
2015-10-15 09:50:25 +00:00
|
|
|
}
|
2017-03-03 17:44:28 +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);
|
|
|
|
if (!_description.empty())
|
2019-12-11 16:31:36 +00:00
|
|
|
*this << util::errinfo_comment(_description);
|
2015-10-15 09:50:25 +00:00
|
|
|
}
|
2017-02-24 18:31:20 +00:00
|
|
|
|
2019-02-14 10:37:24 +00:00
|
|
|
Error::Error(Error::Type _type, std::string const& _description, SourceLocation const& _location):
|
2017-02-15 13:52:53 +00:00
|
|
|
Error(_type)
|
|
|
|
{
|
2020-02-03 07:04:21 +00:00
|
|
|
if (_location.isValid())
|
2017-02-15 13:52:53 +00:00
|
|
|
*this << errinfo_sourceLocation(_location);
|
2019-12-11 16:31:36 +00:00
|
|
|
*this << util::errinfo_comment(_description);
|
2017-02-15 13:52:53 +00:00
|
|
|
}
|