diff options
author | Chris Bieneman <beanz@apple.com> | 2016-05-12 01:52:33 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-05-12 01:52:33 +0000 |
commit | de60ad33b37e19cbf73b53feed6428886d358f02 (patch) | |
tree | debc8251e5d1c6a43bf33bd502318004fdad07f9 /llvm/tools/obj2yaml/Error.h | |
parent | 9926a5e31de0834d7a70bf1837777b94a72e5111 (diff) | |
download | bcm5719-llvm-de60ad33b37e19cbf73b53feed6428886d358f02.tar.gz bcm5719-llvm-de60ad33b37e19cbf73b53feed6428886d358f02.zip |
[obj2yaml] Adding Error/Expected to macho2yaml
I figure if I'm adding Mach support I may as well use the new fancy Error model.
llvm-svn: 269264
Diffstat (limited to 'llvm/tools/obj2yaml/Error.h')
-rw-r--r-- | llvm/tools/obj2yaml/Error.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/tools/obj2yaml/Error.h b/llvm/tools/obj2yaml/Error.h index 7be92e9aace..f4e191c872c 100644 --- a/llvm/tools/obj2yaml/Error.h +++ b/llvm/tools/obj2yaml/Error.h @@ -10,6 +10,8 @@ #ifndef LLVM_TOOLS_OBJ2YAML_ERROR_H #define LLVM_TOOLS_OBJ2YAML_ERROR_H +#include "llvm/Support/Error.h" + #include <system_error> namespace llvm { @@ -27,6 +29,22 @@ inline std::error_code make_error_code(obj2yaml_error e) { return std::error_code(static_cast<int>(e), obj2yaml_category()); } +class Obj2YamlError : public ErrorInfo<Obj2YamlError> { +public: + static char ID; + Obj2YamlError(obj2yaml_error C) : Code(C) {} + Obj2YamlError(const std::string &ErrMsg) : ErrMsg(std::move(ErrMsg)) {} + Obj2YamlError(obj2yaml_error C, std::string ErrMsg) + : ErrMsg(std::move(ErrMsg)), Code(C) {} + void log(raw_ostream &OS) const override; + const std::string &getErrorMessage() const { return ErrMsg; } + std::error_code convertToErrorCode() const override; + +private: + std::string ErrMsg; + obj2yaml_error Code; +}; + } // namespace llvm namespace std { |