DUDS
Distributed Update of Data from Something
Errors.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
15 #ifndef ERRORS_HPP
16 #define ERRORS_HPP
17 
18 #include <boost/exception/exception.hpp>
19 #include <boost/exception/info.hpp>
20 #include <boost/current_function.hpp>
21 #include <exception>
22 
23 #ifdef DUDS_ERRORS_TERSE
24 #define DUDS_THROW_EXCEPTION(x) ::boost::throw_exception(x)
25 #elif defined(DUDS_ERRORS_VERBOSE) || defined(DOXYGEN)
26 
30 #define BOOST_STACKTRACE_USE_ADDR2LINE
31 #include <boost/stacktrace.hpp>
48 #define DUDS_THROW_EXCEPTION(x) \
49  ::boost::throw_exception(::boost::enable_error_info(x) << \
50  ::boost::throw_function(BOOST_CURRENT_FUNCTION) << \
51  ::boost::throw_file(__FILE__) << ::boost::throw_line((int)__LINE__) << \
52  duds::general::StackTrace(boost::stacktrace::stacktrace()))
53 #else
54 #define DUDS_THROW_EXCEPTION(x) BOOST_THROW_EXCEPTION(x)
55 #endif
56 
57 namespace duds { namespace general {
58 
59 #if defined(DUDS_ERRORS_VERBOSE) || defined(DOXYGEN)
60 
73 typedef boost::error_info<
74  struct Info_Stacktrace,
75  boost::stacktrace::stacktrace
77 #endif
78 
85 struct ObjectDestructedError : virtual std::exception, virtual boost::exception { };
86 
90 struct UnimplementedError : virtual std::exception, virtual boost::exception { };
91 
95 struct IoError : virtual std::exception, virtual boost::exception { };
96 
100 struct ChecksumError : IoError { };
101 
105 struct CrcError : ChecksumError { };
106 
111 struct FileIoError : IoError { };
112 
113 } }
114 
115 #endif // #ifndef ERRORS_HPP
A bad checksum value was found.
Definition: Errors.hpp:100
Indicates that the requested operation or called function is not implemented.
Definition: Errors.hpp:90
An error indicating an attempt to use an already destructed object.
Definition: Errors.hpp:85
boost::error_info< struct Info_Stacktrace, boost::stacktrace::stacktrace > StackTrace
Includes stack trace information in an exception.
Definition: Errors.hpp:76
A general I/O error.
Definition: Errors.hpp:95
An I/O error involving a file.
Definition: Errors.hpp:111
An incorrect cyclic redundancy code (CRC) value was found.
Definition: Errors.hpp:105