HART  0.1.0
High level Audio Regression and Testing
Loading...
Searching...
No Matches
hart_exceptions.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <stdexcept>
5
6namespace hart
7{
8
10 public std::runtime_error
11{
12 using std::runtime_error::runtime_error;
13};
14
15class IOError:
16 public std::runtime_error
17{
18 using std::runtime_error::runtime_error;
19};
20
22 public std::runtime_error
23{
24 using std::runtime_error::runtime_error;
25};
26
28 public std::runtime_error
29{
30 using std::runtime_error::runtime_error;
31};
32
34 public std::runtime_error
35{
36 using std::runtime_error::runtime_error;
37};
38
40 public std::runtime_error
41{
42 using std::runtime_error::runtime_error;
43};
44
46 public std::runtime_error
47{
48 using std::runtime_error::runtime_error;
49};
50
52 public std::runtime_error
53{
54 using std::runtime_error::runtime_error;
55};
56
58 public std::runtime_error
59{
60 using std::runtime_error::runtime_error;
61};
62
64 public std::runtime_error
65{
66 using std::runtime_error::runtime_error;
67};
68
70 public std::runtime_error
71{
72 using std::runtime_error::runtime_error;
73};
74
75#ifndef HART_STRINGIFY
76#define HART_STRINGIFY(x) HART_STRINGIFY2(x)
77#define HART_STRINGIFY2(x) #x
78#endif // HART_STRINGIFY
79
80#define HART_LINE_STRING HART_STRINGIFY(__LINE__)
81
82#if HART_DO_NOT_THROW_EXCEPTIONS
83#define HART_THROW(ExceptionType, message) do { std::cout << #ExceptionType << " triggered: \"" << message << "\", file: " << __FILE__ << ", line: " << __LINE__ << std::endl; } while (0)
84#else
85#define HART_THROW(ExceptionType, message) do { throw ExceptionType (std::string (message) + ", file: " __FILE__ ", line: " HART_LINE_STRING); } while (0)
86#endif // HART_DO_NOT_THROW_EXCEPTIONS
87
88#define HART_THROW_OR_RETURN(ExceptionType, message, returnValue) do { HART_THROW (ExceptionType, message); return returnValue; } while (0)
89#define HART_THROW_OR_RETURN_VOID(ExceptionType, message) do { HART_THROW (ExceptionType, message); return; } while(0)
90
91#define hassertfalse HART_THROW (hart::HartAssertException, "hassertfalse failed")
92#define hassert(condition) if (! (condition)) { HART_THROW (hart::HartAssertException, std::string ("hassert failed:") + #condition); }
93
94#define HART_WARNING(message) std::cout << "Warning: " << message << ", file: " << __FILE__ << ", line: " << __LINE__ << std::endl
95
96} // namespace hart
#define HART_LINE_STRING
#define HART_STRINGIFY(x)
#define HART_STRINGIFY2(x)
#define HART_THROW(ExceptionType, message)