9#ifndef LLDB_UTILITY_STATUS_H
10#define LLDB_UTILITY_STATUS_H
15#include "llvm/ADT/StringRef.h"
16#include "llvm/Support/Error.h"
17#include "llvm/Support/FormatVariadic.h"
21#include <system_error>
35 :
public llvm::ErrorInfo<CloneableError, llvm::ErrorInfoBase> {
37 using llvm::ErrorInfo<
CloneableError, llvm::ErrorInfoBase>::ErrorInfo;
39 virtual std::unique_ptr<CloneableError>
Clone()
const = 0;
46 :
public llvm::ErrorInfo<CloneableECError, CloneableError> {
50 void log(llvm::raw_ostream &
OS)
const override {
OS <<
EC.message(); }
61 :
public llvm::ErrorInfo<MachKernelError, CloneableECError> {
65 std::string
message()
const override;
66 std::unique_ptr<CloneableError>
Clone()
const override;
71class Win32Error :
public llvm::ErrorInfo<Win32Error, CloneableECError> {
74 Win32Error(std::error_code ec,
const llvm::Twine &msg = {}) : ErrorInfo(ec) {}
75 std::string
message()
const override;
76 std::unique_ptr<CloneableError>
Clone()
const override;
131 std::string msg = {});
133 Status(std::error_code EC);
136 explicit Status(std::string err_str);
140 return Status(std::string(str));
141 return Status(std::string(
"null error"));
145 __attribute__((format(printf, 1, 2)));
147 template <typename...
Args>
149 return Status(llvm::formatv(format, std::forward<Args>(args)...));
184 const char *
AsCString(
const char *default_error_str =
"unknown error")
const;
241 llvm::StringRef Options);
245#define LLDB_ERRORF(status, fmt, ...) \
248 (status)->SetErrorStringWithFormat((fmt), __VA_ARGS__); \
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
Common base class for all error-code errors.
CloneableECError()=delete
void log(llvm::raw_ostream &OS) const override
lldb::ErrorType GetErrorType() const override
std::error_code convertToErrorCode() const override
CloneableECError(std::error_code ec)
Going a bit against the spirit of llvm::Error, lldb_private::Status need to store errors long-term an...
virtual std::unique_ptr< CloneableError > Clone() const =0
virtual lldb::ErrorType GetErrorType() const =0
FIXME: Move these declarations closer to where they're used.
std::string message() const override
std::unique_ptr< CloneableError > Clone() const override
MachKernelError(std::error_code ec)
lldb::ErrorType GetErrorType() const override
uint32_t ValueType
into ValueType.
void Clear()
Clear the object state.
static Status FromErrno()
Set the current error to errno.
Status(Status &&other)=default
lldb::ErrorType GetType() const
Access the error type.
Status Clone() const
Don't call this function in new code.
ValueType GetError() const
Access the error value.
Status(llvm::Error error)
llvm::Error ToError() const
FIXME: Replace all uses with takeError() instead.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
const Status & operator=(Status &&)
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
bool Success() const
Test for success condition.
std::string m_string
TODO: Replace this with just calling toString(m_error).
Win32Error(std::error_code ec, const llvm::Twine &msg={})
std::string message() const override
lldb::ErrorType GetErrorType() const override
std::unique_ptr< CloneableError > Clone() const override
A class that represents a running process on the host machine.
@ eErrorTypeGeneric
Generic errors that can be any value.