Skip to content

Commit ca2ff2a

Browse files
committed
[lldb/API] Add convenience constructor for SBError (NFC)
This patch adds a new convience constructor to the SBError to initialize it with a string message to avoid having to create the object and call the `SetErrorString` method afterwards. This is very handy to report errors from lldb scripted affordances. Differential Revision: https://reviews.llvm.org/D148401 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 055ea41 commit ca2ff2a

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

lldb/bindings/interface/SBError.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class SBError {
5959
public:
6060
SBError ();
6161

62+
SBError(const char *message);
63+
6264
SBError (const lldb::SBError &rhs);
6365

6466
~SBError();

lldb/include/lldb/API/SBError.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class LLDB_API SBError {
2323

2424
SBError(const lldb::SBError &rhs);
2525

26+
SBError(const char *message);
27+
2628
SBError(const lldb_private::Status &error);
2729

2830
~SBError();

lldb/source/API/SBError.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ SBError::SBError(const SBError &rhs) {
2525
m_opaque_up = clone(rhs.m_opaque_up);
2626
}
2727

28+
SBError::SBError(const char *message) {
29+
LLDB_INSTRUMENT_VA(this, message);
30+
31+
SetErrorString(message);
32+
}
33+
2834
SBError::SBError(const lldb_private::Status &status)
2935
: m_opaque_up(new Status(status)) {
3036
LLDB_INSTRUMENT_VA(this, status);

0 commit comments

Comments
 (0)