Loading...
Searching...
No Matches
ErrorManager.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) gpridge developers
3// See LICENSE for details.
4
5/*
6 * ErrorManager.h
7 *
8 * Created on: 17 Jun 2020
9 * Author: Maxim Masterov
10 * Company: SURFSara
11 */
12
13#ifndef MANAGERS_IO_ERRORMANAGER_H_
14#define MANAGERS_IO_ERRORMANAGER_H_
15
16#include <cstdlib>
17#include <iostream>
18#include <string>
19
20namespace gpr {
21namespace io {
22
27public:
30
36 template <typename T>
37 inline ErrorManager& operator<<(const T& data)
38 {
39 // NOTE: logs to stderr; file logging uses LogManager
40 std::cerr << data;
41 return *this;
42 }
43
52 inline static void assertMsg(const bool expression,
53 const std::string& message, const char* file,
54 const char* func, const int line)
55 {
56 if (!expression) {
57 std::cerr << "[ " << file << "]::" << func << "::" << line << " "
58 << message << "\n";
59 exit(1);
60 }
61 }
62};
63
64} /* namespace io */
65} /* namespace gpr */
66
67#define assertMsg(expression, msg) \
68 io::ErrorManager::assertMsg(expression, msg, __FILE__, __FUNCTION__, \
69 __LINE__)
70
71#endif /* MANAGERS_IO_ERRORMANAGER_H_ */
ErrorManager & operator<<(const T &data)
Writes data to the log.
static void assertMsg(const bool expression, const std::string &message, const char *file, const char *func, const int line)
Prints error message and terminates the program.
Gaussian-process regression, kernels, priors, and the searches that run on the surrogate.
Definition Macros.h:16