mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add Error::parseErrorType()
This commit is contained in:
parent
fe1f9c640e
commit
fc37b4eeb6
@ -29,6 +29,26 @@
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
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"},
|
||||
};
|
||||
|
||||
Error::Error(
|
||||
ErrorId _errorId, Error::Type _type,
|
||||
std::string const& _description,
|
||||
|
@ -33,10 +33,11 @@
|
||||
#include <boost/preprocessor/facilities/overload.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
|
||||
#include <optional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <variant>
|
||||
|
||||
namespace solidity::langutil
|
||||
@ -269,27 +270,17 @@ public:
|
||||
|
||||
static std::string formatErrorType(Type _type)
|
||||
{
|
||||
switch (_type)
|
||||
{
|
||||
case Type::IOError: return "IOError";
|
||||
case Type::FatalError: return "FatalError";
|
||||
case Type::JSONError: return "JSONError";
|
||||
case Type::InternalCompilerError: return "InternalCompilerError";
|
||||
case Type::CompilerError: return "CompilerError";
|
||||
case Type::Exception: return "Exception";
|
||||
case Type::CodeGenerationError: return "CodeGenerationError";
|
||||
case Type::DeclarationError: return "DeclarationError";
|
||||
case Type::DocstringParsingError: return "DocstringParsingError";
|
||||
case Type::ParserError: return "ParserError";
|
||||
case Type::SyntaxError: return "SyntaxError";
|
||||
case Type::TypeError: return "TypeError";
|
||||
case Type::UnimplementedFeatureError: return "UnimplementedFeatureError";
|
||||
case Type::YulException: return "YulException";
|
||||
case Type::SMTLogicException: return "SMTLogicException";
|
||||
case Type::Warning: return "Warning";
|
||||
case Type::Info: return "Info";
|
||||
}
|
||||
util::unreachable();
|
||||
return m_errorTypeNames.at(_type);
|
||||
}
|
||||
|
||||
static std::optional<Type> parseErrorType(std::string _name)
|
||||
{
|
||||
static std::map<std::string, Error::Type> const m_errorTypesByName = util::invertMap(m_errorTypeNames);
|
||||
|
||||
if (m_errorTypesByName.count(_name) == 0)
|
||||
return std::nullopt;
|
||||
|
||||
return m_errorTypesByName.at(_name);
|
||||
}
|
||||
|
||||
static std::string formatTypeOrSeverity(std::variant<Error::Type, Error::Severity> _typeOrSeverity)
|
||||
@ -309,6 +300,8 @@ public:
|
||||
private:
|
||||
ErrorId m_errorId;
|
||||
Type m_type;
|
||||
|
||||
static std::map<Type, std::string> const m_errorTypeNames;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user