aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/Exceptions.h
diff options
context:
space:
mode:
authorLianaHus <liana@ethdev.com>2015-10-15 02:37:41 +0800
committerLianaHus <liana@ethdev.com>2015-10-15 02:37:41 +0800
commitc3491e446964f366101f28e3d51ab59dd9aaa5b2 (patch)
tree75a261126d7c0eb7919db32603aea44e5fe443ba /libsolidity/Exceptions.h
parent8f7f22c5a6b1a71d7baff489b6425670550e8e8b (diff)
downloaddexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.tar
dexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.tar.gz
dexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.tar.bz2
dexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.tar.lz
dexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.tar.xz
dexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.tar.zst
dexon-solidity-c3491e446964f366101f28e3d51ab59dd9aaa5b2.zip
errors instead of exceptions
Conflicts: libsolidity/CompilerStack.cpp libsolidity/NameAndTypeResolver.cpp libsolidity/NameAndTypeResolver.h libsolidity/TypeChecker.cpp test/libsolidity/SolidityNameAndTypeResolution.cpp
Diffstat (limited to 'libsolidity/Exceptions.h')
-rw-r--r--libsolidity/Exceptions.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/libsolidity/Exceptions.h b/libsolidity/Exceptions.h
index 5a1b827c..92c009ef 100644
--- a/libsolidity/Exceptions.h
+++ b/libsolidity/Exceptions.h
@@ -26,11 +26,18 @@
#include <utility>
#include <libdevcore/Exceptions.h>
#include <libevmasm/SourceLocation.h>
+#include <libsolidity/Utils.h>
namespace dev
{
namespace solidity
{
+class Error;
+using ErrorList = std::vector<std::shared_ptr<Error const>>;
+
+struct CompilerError: virtual Exception {};
+struct InternalCompilerError: virtual Exception {};
+struct fatalError: virtual Exception {}; //todo rename to FatalError
class Error: virtual public Exception
{
@@ -41,7 +48,6 @@ public:
DocstringParsingError,
ParserError,
TypeError,
-
Warning
};
@@ -65,22 +71,39 @@ public:
m_typeName = "Warning";
break;
default:
- m_typeName = "Error";
+ solAssert(false, "");
break;
}
}
- Type const type() { return m_type; } const
+ Type type() const { return m_type; }
std::string const& typeName() const { return m_typeName; }
+
+ /// helper functions
+ static Error const* containsErrorOfType(ErrorList const& _list, Error::Type _type)
+ {
+ for (auto e: _list)
+ {
+ if(e->type() == _type)
+ return e.get();
+ }
+ return nullptr;
+ }
+ static bool containsOnlyWarnings(ErrorList const& _list)
+ {
+ for (auto e: _list)
+ {
+ if(e->type() != Type::Warning)
+ return false;
+ }
+ return true;
+ }
private:
Type m_type;
std::string m_typeName;
};
-struct CompilerError: virtual Exception {};
-struct InternalCompilerError: virtual Exception {};
-struct FatalError: virtual Exception {};
using errorSourceLocationInfo = std::pair<std::string, SourceLocation>;
@@ -96,7 +119,6 @@ public:
};
-using ErrorList = std::vector<std::shared_ptr<Error const>>;
using errinfo_sourceLocation = boost::error_info<struct tag_sourceLocation, SourceLocation>;
using errinfo_secondarySourceLocation = boost::error_info<struct tag_secondarySourceLocation, SecondarySourceLocation>;