TARAXA
Exceptions.h
Go to the documentation of this file.
1 // Aleth: Ethereum C++ client, tools and libraries.
2 // Copyright 2014-2019 Aleth Authors.
3 // Licensed under the GNU General Public License, Version 3.
4 
5 #pragma once
6 
7 #include <boost/exception/diagnostic_information.hpp>
8 #include <boost/exception/errinfo_api_function.hpp>
9 #include <boost/exception/exception.hpp>
10 #include <boost/exception/info.hpp>
11 #include <boost/exception/info_tuple.hpp>
12 #include <boost/throw_exception.hpp>
13 #include <boost/tuple/tuple.hpp>
14 #include <exception>
15 #include <string>
16 
17 #include "FixedHash.h"
18 
19 namespace dev {
21 struct Exception : virtual std::exception, virtual boost::exception {
22  const char* what() const noexcept override { return boost::diagnostic_information_what(*this); }
23 };
24 
25 #define DEV_SIMPLE_EXCEPTION(X) \
26  struct X : virtual ::dev::Exception {}
27 
29 struct RLPException : virtual Exception {};
30 #define DEV_SIMPLE_EXCEPTION_RLP(X) \
31  struct X : virtual ::dev::RLPException {}
32 
37 
38 DEV_SIMPLE_EXCEPTION(BadHexCharacter);
39 DEV_SIMPLE_EXCEPTION(NoNetworking);
40 DEV_SIMPLE_EXCEPTION(NoUPnPDevice);
41 DEV_SIMPLE_EXCEPTION(RootNotFound);
45 DEV_SIMPLE_EXCEPTION(FailedInvariant);
46 DEV_SIMPLE_EXCEPTION(ValueTooLarge);
47 DEV_SIMPLE_EXCEPTION(UnknownField);
48 DEV_SIMPLE_EXCEPTION(MissingField);
49 DEV_SIMPLE_EXCEPTION(WrongFieldType);
50 DEV_SIMPLE_EXCEPTION(InterfaceNotSupported);
51 DEV_SIMPLE_EXCEPTION(ExternalFunctionFailure);
52 DEV_SIMPLE_EXCEPTION(WaitTimeout);
53 
54 // error information to be added to exceptions
55 using errinfo_invalidSymbol = boost::error_info<struct tag_invalidSymbol, char>;
56 using errinfo_wrongAddress = boost::error_info<struct tag_address, std::string>;
57 using errinfo_comment = boost::error_info<struct tag_comment, std::string>;
58 using errinfo_required = boost::error_info<struct tag_required, bigint>;
59 using errinfo_got = boost::error_info<struct tag_got, bigint>;
60 using errinfo_min = boost::error_info<struct tag_min, bigint>;
61 using errinfo_max = boost::error_info<struct tag_max, bigint>;
62 using RequirementError = boost::tuple<errinfo_required, errinfo_got>;
63 using RequirementErrorComment = boost::tuple<errinfo_required, errinfo_got, errinfo_comment>;
64 using errinfo_hash256 = boost::error_info<struct tag_hash, h256>;
65 using errinfo_required_h256 = boost::error_info<struct tag_required_h256, h256>;
66 using errinfo_got_h256 = boost::error_info<struct tag_get_h256, h256>;
67 using Hash256RequirementError = boost::tuple<errinfo_required_h256, errinfo_got_h256>;
68 using errinfo_extraData = boost::error_info<struct tag_extraData, bytes>;
69 using errinfo_externalFunction = boost::errinfo_api_function;
70 using errinfo_interface = boost::error_info<struct tag_interface, std::string>;
71 using errinfo_path = boost::error_info<struct tag_path, std::string>;
72 using errinfo_nodeID = boost::error_info<struct tag_nodeID, h512>;
73 } // namespace dev
Definition: Address.h:13
boost::error_info< struct tag_hash, h256 > errinfo_hash256
Definition: Exceptions.h:64
boost::tuple< errinfo_required, errinfo_got > RequirementError
Definition: Exceptions.h:62
boost::error_info< struct tag_address, std::string > errinfo_wrongAddress
Definition: Exceptions.h:56
boost::error_info< struct tag_min, bigint > errinfo_min
Definition: Exceptions.h:60
DEV_SIMPLE_EXCEPTION(BadHexCharacter)
boost::error_info< struct tag_required_h256, h256 > errinfo_required_h256
Definition: Exceptions.h:65
boost::error_info< struct tag_path, std::string > errinfo_path
Definition: Exceptions.h:71
boost::tuple< errinfo_required_h256, errinfo_got_h256 > Hash256RequirementError
Definition: Exceptions.h:67
boost::error_info< struct tag_required, bigint > errinfo_required
Definition: Exceptions.h:58
DEV_SIMPLE_EXCEPTION_RLP(BadCast)
boost::error_info< struct tag_comment, std::string > errinfo_comment
Definition: Assertions.h:50
boost::error_info< struct tag_interface, std::string > errinfo_interface
Definition: Exceptions.h:70
boost::errinfo_api_function errinfo_externalFunction
Definition: Exceptions.h:69
boost::error_info< struct tag_extraData, bytes > errinfo_extraData
Definition: Exceptions.h:68
boost::error_info< struct tag_max, bigint > errinfo_max
Definition: Exceptions.h:61
boost::error_info< struct tag_invalidSymbol, char > errinfo_invalidSymbol
Definition: Exceptions.h:55
boost::error_info< struct tag_got, bigint > errinfo_got
Definition: Exceptions.h:59
boost::error_info< struct tag_get_h256, h256 > errinfo_got_h256
Definition: Exceptions.h:66
boost::error_info< struct tag_nodeID, h512 > errinfo_nodeID
Definition: Exceptions.h:72
boost::tuple< errinfo_required, errinfo_got, errinfo_comment > RequirementErrorComment
Definition: Exceptions.h:63
Base class for all exceptions.
Definition: Exceptions.h:21
const char * what() const noexcept override
Definition: Exceptions.h:22
Base class for all RLP exceptions.
Definition: Exceptions.h:29