iodrivers_base
Exceptions.hpp
Go to the documentation of this file.
1 #ifndef IODRIVERS_BASE_EXCEPTIONS_HPP
2 #define IODRIVERS_BASE_EXCEPTIONS_HPP
3 
4 #include <string>
5 #include <stdexcept>
6 #include <exception>
7 
8 namespace iodrivers_base
9 {
10 
13 struct UnixError : std::runtime_error
14 {
15  int const error;
16  explicit UnixError(std::string const& desc);
17 
18  UnixError(std::string const& desc, int error_code);
19 };
20 
22 struct TimeoutError : std::runtime_error
23 {
25  { NONE, PACKET, FIRST_BYTE };
26 
28 
29  explicit TimeoutError(TIMEOUT_TYPE type, std::string const& desc)
30  : std::runtime_error(desc)
31  , type(type) {}
32 };
33 
34 }
35 class MockContextException : public std::exception
36 {
37  public:
38  const char * what() const throw()
39  {
40  return "IODRIVERS_BASE_MOCK Error: Expectation set outside Mock Context! Please call IODRIVERS_BASE_MOCK() before setting expectations";
41  }
42 };
43 
44 class TestEndsWithExpectationsLeftException : public std::exception
45 {
46  public:
47  const char * what() const throw()
48  {
49  return "IODRIVERS_BASE_MOCK Error: Test reached its end without satisfying all expecations";
50  }
51 };
52 
53 #endif
54 
UnixError(std::string const &desc)
Definition: Exceptions.cpp:7
const char * what() const
Definition: Exceptions.hpp:47
TIMEOUT_TYPE type
Definition: Exceptions.hpp:27
int const error
Definition: Exceptions.hpp:15
Definition: Bus.hpp:9
Definition: Exceptions.hpp:35
Definition: Exceptions.hpp:25
Definition: Exceptions.hpp:13
Definition: Exceptions.hpp:44
const char * what() const
Definition: Exceptions.hpp:38
TIMEOUT_TYPE
Definition: Exceptions.hpp:24
Definition: Exceptions.hpp:22
TimeoutError(TIMEOUT_TYPE type, std::string const &desc)
Definition: Exceptions.hpp:29