Ethereum  PoC-8
The C++ Implementation of Ethereum
Exceptions.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #pragma once
23 
24 #include "FixedHash.h"
25 #include <boost/exception/diagnostic_information.hpp>
26 #include <boost/exception/errinfo_api_function.hpp>
27 #include <boost/exception/exception.hpp>
28 #include <boost/exception/info.hpp>
29 #include <boost/exception/info_tuple.hpp>
30 #include <boost/throw_exception.hpp>
31 #include <boost/tuple/tuple.hpp>
32 #include <exception>
33 #include <string>
34 
35 namespace dev
36 {
38 struct Exception : virtual std::exception, virtual boost::exception
39 {
40  const char* what() const noexcept override { return boost::diagnostic_information_what(*this); }
41 };
42 
43 #define DEV_SIMPLE_EXCEPTION(X) \
44  struct X : virtual Exception \
45  { \
46  }
47 
49 struct RLPException : virtual Exception
50 {
51 };
52 #define DEV_SIMPLE_EXCEPTION_RLP(X) \
53  struct X : virtual RLPException \
54  { \
55  }
56 
61 
62 DEV_SIMPLE_EXCEPTION(BadHexCharacter);
63 DEV_SIMPLE_EXCEPTION(NoNetworking);
64 DEV_SIMPLE_EXCEPTION(NoUPnPDevice);
65 DEV_SIMPLE_EXCEPTION(RootNotFound);
69 DEV_SIMPLE_EXCEPTION(FailedInvariant);
70 DEV_SIMPLE_EXCEPTION(ValueTooLarge);
71 DEV_SIMPLE_EXCEPTION(UnknownField);
72 DEV_SIMPLE_EXCEPTION(MissingField);
73 DEV_SIMPLE_EXCEPTION(SyntaxError);
74 DEV_SIMPLE_EXCEPTION(WrongFieldType);
75 DEV_SIMPLE_EXCEPTION(InterfaceNotSupported);
76 DEV_SIMPLE_EXCEPTION(ExternalFunctionFailure);
77 DEV_SIMPLE_EXCEPTION(WaitTimeout);
78 
79 // error information to be added to exceptions
80 using errinfo_invalidSymbol = boost::error_info<struct tag_invalidSymbol, char>;
81 using errinfo_wrongAddress = boost::error_info<struct tag_address, std::string>;
82 using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
83 using errinfo_required = boost::error_info<struct tag_required, bigint>;
84 using errinfo_got = boost::error_info<struct tag_got, bigint>;
85 using errinfo_min = boost::error_info<struct tag_min, bigint>;
86 using errinfo_max = boost::error_info<struct tag_max, bigint>;
87 using RequirementError = boost::tuple<errinfo_required, errinfo_got>;
88 using RequirementErrorComment = boost::tuple<errinfo_required, errinfo_got, errinfo_comment>;
89 using errinfo_hash256 = boost::error_info<struct tag_hash, h256>;
90 using errinfo_required_h256 = boost::error_info<struct tag_required_h256, h256>;
91 using errinfo_got_h256 = boost::error_info<struct tag_get_h256, h256>;
92 using Hash256RequirementError = boost::tuple<errinfo_required_h256, errinfo_got_h256>;
93 using errinfo_extraData = boost::error_info<struct tag_extraData, bytes>;
94 using errinfo_externalFunction = boost::errinfo_api_function;
95 using errinfo_interface = boost::error_info<struct tag_interface, std::string>;
96 using errinfo_path = boost::error_info<struct tag_path, std::string>;
97 using errinfo_nodeID = boost::error_info<struct tag_nodeID, h512>;
98 }
dev::errinfo_wrongAddress
boost::error_info< struct tag_address, std::string > errinfo_wrongAddress
Definition: Exceptions.h:81
dev::errinfo_externalFunction
boost::errinfo_api_function errinfo_externalFunction
Definition: Exceptions.h:94
dev::errinfo_invalidSymbol
boost::error_info< struct tag_invalidSymbol, char > errinfo_invalidSymbol
Definition: Exceptions.h:80
FixedHash.h
dev::errinfo_hash256
boost::error_info< struct tag_hash, h256 > errinfo_hash256
Definition: Exceptions.h:89
dev::errinfo_extraData
boost::error_info< struct tag_extraData, bytes > errinfo_extraData
Definition: Exceptions.h:93
dev::RLPException
Base class for all RLP exceptions.
Definition: Exceptions.h:50
dev::errinfo_path
boost::error_info< struct tag_path, std::string > errinfo_path
Definition: Exceptions.h:96
dev::errinfo_nodeID
boost::error_info< struct tag_nodeID, h512 > errinfo_nodeID
Definition: Exceptions.h:97
dev::Exception
Base class for all exceptions.
Definition: Exceptions.h:39
dev::errinfo_required
boost::error_info< struct tag_required, bigint > errinfo_required
Definition: Exceptions.h:83
dev::errinfo_min
boost::error_info< struct tag_min, bigint > errinfo_min
Definition: Exceptions.h:85
dev::RequirementErrorComment
boost::tuple< errinfo_required, errinfo_got, errinfo_comment > RequirementErrorComment
Definition: Exceptions.h:88
dev::errinfo_got
boost::error_info< struct tag_got, bigint > errinfo_got
Definition: Exceptions.h:84
dev::errinfo_required_h256
boost::error_info< struct tag_required_h256, h256 > errinfo_required_h256
Definition: Exceptions.h:90
dev::DEV_SIMPLE_EXCEPTION_RLP
DEV_SIMPLE_EXCEPTION_RLP(BadCast)
dev::errinfo_max
boost::error_info< struct tag_max, bigint > errinfo_max
Definition: Exceptions.h:86
dev::errinfo_got_h256
boost::error_info< struct tag_get_h256, h256 > errinfo_got_h256
Definition: Exceptions.h:91
dev::Hash256RequirementError
boost::tuple< errinfo_required_h256, errinfo_got_h256 > Hash256RequirementError
Definition: Exceptions.h:92
dev
Definition: Address.cpp:21
dev::RequirementError
boost::tuple< errinfo_required, errinfo_got > RequirementError
Definition: Exceptions.h:87
dev::DEV_SIMPLE_EXCEPTION
DEV_SIMPLE_EXCEPTION(BadHexCharacter)
dev::Exception::what
const char * what() const noexcept override
Definition: Exceptions.h:40
dev::errinfo_interface
boost::error_info< struct tag_interface, std::string > errinfo_interface
Definition: Exceptions.h:95
dev::errinfo_comment
boost::error_info< struct tag_comment, std::string > errinfo_comment
Definition: Assertions.h:69