10b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/Native/RawError.h" 20b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h" 30b57cec5SDimitry Andric 40b57cec5SDimitry Andric using namespace llvm; 50b57cec5SDimitry Andric using namespace llvm::pdb; 60b57cec5SDimitry Andric 70b57cec5SDimitry Andric namespace { 80b57cec5SDimitry Andric // FIXME: This class is only here to support the transition to llvm::Error. It 90b57cec5SDimitry Andric // will be removed once this transition is complete. Clients should prefer to 100b57cec5SDimitry Andric // deal with the Error value directly, rather than converting to error_code. 110b57cec5SDimitry Andric class RawErrorCategory : public std::error_category { 120b57cec5SDimitry Andric public: name() const130b57cec5SDimitry Andric const char *name() const noexcept override { return "llvm.pdb.raw"; } message(int Condition) const140b57cec5SDimitry Andric std::string message(int Condition) const override { 150b57cec5SDimitry Andric switch (static_cast<raw_error_code>(Condition)) { 160b57cec5SDimitry Andric case raw_error_code::unspecified: 170b57cec5SDimitry Andric return "An unknown error has occurred."; 180b57cec5SDimitry Andric case raw_error_code::feature_unsupported: 190b57cec5SDimitry Andric return "The feature is unsupported by the implementation."; 200b57cec5SDimitry Andric case raw_error_code::invalid_format: 210b57cec5SDimitry Andric return "The record is in an unexpected format."; 220b57cec5SDimitry Andric case raw_error_code::corrupt_file: 230b57cec5SDimitry Andric return "The PDB file is corrupt."; 240b57cec5SDimitry Andric case raw_error_code::insufficient_buffer: 250b57cec5SDimitry Andric return "The buffer is not large enough to read the requested number of " 260b57cec5SDimitry Andric "bytes."; 270b57cec5SDimitry Andric case raw_error_code::no_stream: 280b57cec5SDimitry Andric return "The specified stream could not be loaded."; 290b57cec5SDimitry Andric case raw_error_code::index_out_of_bounds: 300b57cec5SDimitry Andric return "The specified item does not exist in the array."; 310b57cec5SDimitry Andric case raw_error_code::invalid_block_address: 320b57cec5SDimitry Andric return "The specified block address is not valid."; 330b57cec5SDimitry Andric case raw_error_code::duplicate_entry: 340b57cec5SDimitry Andric return "The entry already exists."; 350b57cec5SDimitry Andric case raw_error_code::no_entry: 360b57cec5SDimitry Andric return "The entry does not exist."; 370b57cec5SDimitry Andric case raw_error_code::not_writable: 380b57cec5SDimitry Andric return "The PDB does not support writing."; 390b57cec5SDimitry Andric case raw_error_code::stream_too_long: 400b57cec5SDimitry Andric return "The stream was longer than expected."; 410b57cec5SDimitry Andric case raw_error_code::invalid_tpi_hash: 420b57cec5SDimitry Andric return "The Type record has an invalid hash value."; 430b57cec5SDimitry Andric } 440b57cec5SDimitry Andric llvm_unreachable("Unrecognized raw_error_code"); 450b57cec5SDimitry Andric } 460b57cec5SDimitry Andric }; 470b57cec5SDimitry Andric } // namespace 480b57cec5SDimitry Andric RawErrCategory()49*753f127fSDimitry Andricconst std::error_category &llvm::pdb::RawErrCategory() { 50*753f127fSDimitry Andric static RawErrorCategory RawCategory; 51*753f127fSDimitry Andric return RawCategory; 52*753f127fSDimitry Andric } 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric char RawError::ID; 55