1 //===-- SBError.h -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_API_SBERROR_H
10 #define LLDB_API_SBERROR_H
11 
12 #include "lldb/API/SBDefines.h"
13 
14 namespace lldb_private {
15 class ScriptInterpreter;
16 } // namespace lldb_private
17 
18 namespace lldb {
19 
20 class LLDB_API SBError {
21 public:
22   SBError();
23 
24   SBError(const lldb::SBError &rhs);
25 
26   ~SBError();
27 
28   const SBError &operator=(const lldb::SBError &rhs);
29 
30   const char *GetCString() const;
31 
32   void Clear();
33 
34   bool Fail() const;
35 
36   bool Success() const;
37 
38   uint32_t GetError() const;
39 
40   lldb::ErrorType GetType() const;
41 
42   void SetError(uint32_t err, lldb::ErrorType type);
43 
44   void SetErrorToErrno();
45 
46   void SetErrorToGenericError();
47 
48   void SetErrorString(const char *err_str);
49 
50   int SetErrorStringWithFormat(const char *format, ...)
51       __attribute__((format(printf, 2, 3)));
52 
53   explicit operator bool() const;
54 
55   bool IsValid() const;
56 
57   bool GetDescription(lldb::SBStream &description);
58 
59 protected:
60   friend class SBBreakpoint;
61   friend class SBBreakpointLocation;
62   friend class SBBreakpointName;
63   friend class SBCommandReturnObject;
64   friend class SBCommunication;
65   friend class SBData;
66   friend class SBDebugger;
67   friend class SBHostOS;
68   friend class SBPlatform;
69   friend class SBProcess;
70   friend class SBReproducer;
71   friend class SBStructuredData;
72   friend class SBTarget;
73   friend class SBThread;
74   friend class SBTrace;
75   friend class SBValue;
76   friend class SBWatchpoint;
77   friend class SBFile;
78 
79   friend class lldb_private::ScriptInterpreter;
80 
81   lldb_private::Status *get();
82 
83   lldb_private::Status *operator->();
84 
85   const lldb_private::Status &operator*() const;
86 
87   lldb_private::Status &ref();
88 
89   void SetError(const lldb_private::Status &lldb_error);
90 
91 private:
92   std::unique_ptr<lldb_private::Status> m_opaque_up;
93 
94   void CreateIfNeeded();
95 };
96 
97 } // namespace lldb
98 
99 #endif // LLDB_API_SBERROR_H
100