comparison tools/obj2yaml/Error.h @ 120:1172e4bd9c6f

update 4.0.0
author mir3636
date Fri, 25 Nov 2016 19:14:25 +0900
parents 54457678186b
children c2174574ed3a
comparison
equal deleted inserted replaced
101:34baf5011add 120:1172e4bd9c6f
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 9
10 #ifndef LLVM_TOOLS_OBJ2YAML_ERROR_H 10 #ifndef LLVM_TOOLS_OBJ2YAML_ERROR_H
11 #define LLVM_TOOLS_OBJ2YAML_ERROR_H 11 #define LLVM_TOOLS_OBJ2YAML_ERROR_H
12 12
13 #include "llvm/Support/Error.h"
14
13 #include <system_error> 15 #include <system_error>
14 16
15 namespace llvm { 17 namespace llvm {
16 const std::error_category &obj2yaml_category(); 18 const std::error_category &obj2yaml_category();
17 19
18 enum class obj2yaml_error { 20 enum class obj2yaml_error {
19 success = 0, 21 success = 0,
20 file_not_found, 22 file_not_found,
21 unrecognized_file_format, 23 unrecognized_file_format,
22 unsupported_obj_file_format 24 unsupported_obj_file_format,
25 not_implemented
23 }; 26 };
24 27
25 inline std::error_code make_error_code(obj2yaml_error e) { 28 inline std::error_code make_error_code(obj2yaml_error e) {
26 return std::error_code(static_cast<int>(e), obj2yaml_category()); 29 return std::error_code(static_cast<int>(e), obj2yaml_category());
27 } 30 }
31
32 class Obj2YamlError : public ErrorInfo<Obj2YamlError> {
33 public:
34 static char ID;
35 Obj2YamlError(obj2yaml_error C) : Code(C) {}
36 Obj2YamlError(std::string ErrMsg) : ErrMsg(std::move(ErrMsg)) {}
37 Obj2YamlError(obj2yaml_error C, std::string ErrMsg)
38 : ErrMsg(std::move(ErrMsg)), Code(C) {}
39 void log(raw_ostream &OS) const override;
40 const std::string &getErrorMessage() const { return ErrMsg; }
41 std::error_code convertToErrorCode() const override;
42
43 private:
44 std::string ErrMsg;
45 obj2yaml_error Code;
46 };
28 47
29 } // namespace llvm 48 } // namespace llvm
30 49
31 namespace std { 50 namespace std {
32 template <> struct is_error_code_enum<llvm::obj2yaml_error> : std::true_type {}; 51 template <> struct is_error_code_enum<llvm::obj2yaml_error> : std::true_type {};