SDK  2.1.4 [async]
CloudBackend Software Development Kit - SDK API for C++
ErrorInfo.h
1 #ifndef CBE__util__ErrorInfo_h__
2 #define CBE__util__ErrorInfo_h__
3 
4 #include <iosfwd>
5 #include <string>
6 
7 namespace cbe {
8  namespace util {
9 
10 class Context;
11 
12 struct ErrorInfo {
13  std::string contextStr{};
14 
15  virtual void printError(std::ostream& os) const = 0;
16 
17  explicit operator bool () const;
18  virtual ~ErrorInfo();
19 protected:
20  ErrorInfo(Context&& context);
21  ErrorInfo();
22 };
23 std::ostream& operator<<(std::ostream& os, const ErrorInfo& ei);
24 
25 
26 template <class ErrorT>
28  ErrorInfoImpl();
29  ErrorInfoImpl(Context&& context, ErrorT&& error);
30 
31  template <class ErrorT2>
32  ErrorInfoImpl& operator=(ErrorInfoImpl<ErrorT2>&& rh);
33 
35 
36  ErrorT error{};
37 
38  void printError(std::ostream& os) const final;
39 };
40 
41 template <class ErrorT>
42 ErrorInfoImpl<ErrorT>::ErrorInfoImpl(Context&& context, ErrorT&& error)
43  : ErrorInfo{std::move(context)}, error{std::move(error)} {}
44 
45 template <class ErrorT>
46 ErrorInfoImpl<ErrorT>::ErrorInfoImpl() = default;
47 
48 template <class ErrorT>
49  template <class ErrorT2>
50 ErrorInfoImpl<ErrorT>&
51 ErrorInfoImpl<ErrorT>::operator=(ErrorInfoImpl<ErrorT2>&& rh) {
52  ErrorInfo::operator=(std::move(rh));
53  error = std::move(rh.error);
54  return *this;
55 }
56 
57 template <class ErrorT>
58 void ErrorInfoImpl<ErrorT>::printError(std::ostream& os) const {
59  os << error;
60 }
61 
62  } // namespace util
63 } // namespace cbe
64 
65 
66 #endif // #ifndef CBE__util__ErrorInfo_h__
Root namespace for the CloudBackend SDK API.
Definition: Account.h:22
Definition: Context.h:11
Definition: ErrorInfo.h:27
Definition: ErrorInfo.h:12