Error.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //===- 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. #include "Error.h"
  10. #include "llvm/Support/ErrorHandling.h"
  11. using namespace llvm;
  12. namespace {
  13. class _obj2yaml_error_category : public std::error_category {
  14. public:
  15. const char *name() const LLVM_NOEXCEPT override;
  16. std::string message(int ev) const override;
  17. };
  18. } // namespace
  19. const char *_obj2yaml_error_category::name() const LLVM_NOEXCEPT {
  20. return "obj2yaml";
  21. }
  22. std::string _obj2yaml_error_category::message(int ev) const {
  23. switch (static_cast<obj2yaml_error>(ev)) {
  24. case obj2yaml_error::success:
  25. return "Success";
  26. case obj2yaml_error::file_not_found:
  27. return "No such file.";
  28. case obj2yaml_error::unrecognized_file_format:
  29. return "Unrecognized file type.";
  30. case obj2yaml_error::unsupported_obj_file_format:
  31. return "Unsupported object file format.";
  32. }
  33. llvm_unreachable("An enumerator of obj2yaml_error does not have a message "
  34. "defined.");
  35. }
  36. namespace llvm {
  37. const std::error_category &obj2yaml_category() {
  38. static _obj2yaml_error_category o;
  39. return o;
  40. }
  41. } // namespace llvm