diff options
Diffstat (limited to 'lldb/source/Utility/Status.cpp')
| -rw-r--r-- | lldb/source/Utility/Status.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp index 5757935fb862..49dd469d20bd 100644 --- a/lldb/source/Utility/Status.cpp +++ b/lldb/source/Utility/Status.cpp @@ -252,6 +252,30 @@ lldb::ErrorType Win32Error::GetErrorType() const { return lldb::eErrorTypeWin32; } +StructuredData::ObjectSP Status::GetAsStructuredData() const { + auto dict_up = std::make_unique<StructuredData::Dictionary>(); + auto array_up = std::make_unique<StructuredData::Array>(); + llvm::visitErrors(m_error, [&](const llvm::ErrorInfoBase &error) { + if (error.isA<CloneableError>()) + array_up->AddItem( + static_cast<const CloneableError &>(error).GetAsStructuredData()); + else + array_up->AddStringItem(error.message()); + }); + dict_up->AddIntegerItem("version", 1u); + dict_up->AddIntegerItem("type", (unsigned)GetType()); + dict_up->AddItem("errors", std::move(array_up)); + return dict_up; +} + +StructuredData::ObjectSP CloneableECError::GetAsStructuredData() const { + auto dict_up = std::make_unique<StructuredData::Dictionary>(); + dict_up->AddIntegerItem("version", 1u); + dict_up->AddIntegerItem("error_code", EC.value()); + dict_up->AddStringItem("message", message()); + return dict_up; +} + ErrorType Status::GetType() const { ErrorType result = eErrorTypeInvalid; llvm::visitErrors(m_error, [&](const llvm::ErrorInfoBase &error) { |
