blob: 7be468dd563f9deac7798f572c358be62a79e0ab [file] [log] [blame]
Simon Atanasyanba592972014-05-07 05:18:51 +00001//===- Error.cpp - system_error extensions for obj2yaml ---------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "Error.h"
11#include "llvm/Support/ErrorHandling.h"
12
13using namespace llvm;
14
15namespace {
16class _obj2yaml_error_category : public error_category {
17public:
18 const char *name() const override;
19 std::string message(int ev) const override;
20 error_condition default_error_condition(int ev) const override;
21};
22} // namespace
23
24const char *_obj2yaml_error_category::name() const { return "obj2yaml"; }
25
26std::string _obj2yaml_error_category::message(int ev) const {
27 switch (ev) {
28 case obj2yaml_error::success:
29 return "Success";
30 case obj2yaml_error::file_not_found:
31 return "No such file.";
32 case obj2yaml_error::unrecognized_file_format:
33 return "Unrecognized file type.";
34 case obj2yaml_error::unsupported_obj_file_format:
35 return "Unsupported object file format.";
36 default:
37 llvm_unreachable("An enumerator of obj2yaml_error does not have a message "
38 "defined.");
39 }
40}
41
42error_condition
43_obj2yaml_error_category::default_error_condition(int ev) const {
44 if (ev == obj2yaml_error::success)
45 return errc::success;
46 return errc::invalid_argument;
47}
48
49namespace llvm {
50const error_category &obj2yaml_category() {
51 static _obj2yaml_error_category o;
52 return o;
53}
54} // namespace llvm