-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.h
More file actions
36 lines (28 loc) · 891 Bytes
/
error.h
File metadata and controls
36 lines (28 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2016 Dino Wernli. All Rights Reserved. See LICENSE for licensing terms.
#ifndef ERROR_H_
#define ERROR_H_
#include <sstream>
namespace ccproducers {
class Error {
public:
Error() : cause_(nullptr), message_("") {}
Error(Error&& other) :
cause_(std::move(other.cause_)), message_(std::move(other.message_)) {}
Error(const Error* cause) : cause_(cause), message_("") {}
Error(std::string message) : cause_(nullptr), message_(message) {}
std::string ToString() const {
std::stringstream stream;
stream << "Producer error with message: " << std::endl
<< message_ << std::endl;
if (cause_ != nullptr) {
stream << "Caused by: " << std::endl
<< cause_->ToString() << std::endl;
}
return stream.str();
}
private:
const Error* cause_;
std::string message_;
};
} // namespace ccproducers
#endif // ERROR_H