RawError.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include "llvm/DebugInfo/PDB/Native/RawError.h"
  2. #include "llvm/Support/ErrorHandling.h"
  3. using namespace llvm;
  4. using namespace llvm::pdb;
  5. namespace {
  6. // FIXME: This class is only here to support the transition to llvm::Error. It
  7. // will be removed once this transition is complete. Clients should prefer to
  8. // deal with the Error value directly, rather than converting to error_code.
  9. class RawErrorCategory : public std::error_category {
  10. public:
  11. const char *name() const noexcept override { return "llvm.pdb.raw"; }
  12. std::string message(int Condition) const override {
  13. switch (static_cast<raw_error_code>(Condition)) {
  14. case raw_error_code::unspecified:
  15. return "An unknown error has occurred.";
  16. case raw_error_code::feature_unsupported:
  17. return "The feature is unsupported by the implementation.";
  18. case raw_error_code::invalid_format:
  19. return "The record is in an unexpected format.";
  20. case raw_error_code::corrupt_file:
  21. return "The PDB file is corrupt.";
  22. case raw_error_code::insufficient_buffer:
  23. return "The buffer is not large enough to read the requested number of "
  24. "bytes.";
  25. case raw_error_code::no_stream:
  26. return "The specified stream could not be loaded.";
  27. case raw_error_code::index_out_of_bounds:
  28. return "The specified item does not exist in the array.";
  29. case raw_error_code::invalid_block_address:
  30. return "The specified block address is not valid.";
  31. case raw_error_code::duplicate_entry:
  32. return "The entry already exists.";
  33. case raw_error_code::no_entry:
  34. return "The entry does not exist.";
  35. case raw_error_code::not_writable:
  36. return "The PDB does not support writing.";
  37. case raw_error_code::stream_too_long:
  38. return "The stream was longer than expected.";
  39. case raw_error_code::invalid_tpi_hash:
  40. return "The Type record has an invalid hash value.";
  41. }
  42. llvm_unreachable("Unrecognized raw_error_code");
  43. }
  44. };
  45. } // namespace
  46. const std::error_category &llvm::pdb::RawErrCategory() {
  47. static RawErrorCategory RawCategory;
  48. return RawCategory;
  49. }
  50. char RawError::ID;