13ca95b02SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAError.h" 23ca95b02SDimitry Andric #include "llvm/Support/ErrorHandling.h" 33ca95b02SDimitry Andric #include "llvm/Support/ManagedStatic.h" 43ca95b02SDimitry Andric 53ca95b02SDimitry Andric using namespace llvm; 63ca95b02SDimitry Andric using namespace llvm::pdb; 73ca95b02SDimitry Andric 83ca95b02SDimitry Andric // FIXME: This class is only here to support the transition to llvm::Error. It 93ca95b02SDimitry Andric // will be removed once this transition is complete. Clients should prefer to 103ca95b02SDimitry Andric // deal with the Error value directly, rather than converting to error_code. 113ca95b02SDimitry Andric class DIAErrorCategory : public std::error_category { 123ca95b02SDimitry Andric public: name() const13d88c1a5aSDimitry Andric const char *name() const noexcept override { return "llvm.pdb.dia"; } message(int Condition) const143ca95b02SDimitry Andric std::string message(int Condition) const override { 153ca95b02SDimitry Andric switch (static_cast<dia_error_code>(Condition)) { 163ca95b02SDimitry Andric case dia_error_code::could_not_create_impl: 173ca95b02SDimitry Andric return "Failed to connect to DIA at runtime. Verify that Visual Studio " 183ca95b02SDimitry Andric "is properly installed, or that msdiaXX.dll is in your PATH."; 193ca95b02SDimitry Andric case dia_error_code::invalid_file_format: 203ca95b02SDimitry Andric return "Unable to load PDB. The file has an unrecognized format."; 213ca95b02SDimitry Andric case dia_error_code::invalid_parameter: 223ca95b02SDimitry Andric return "The parameter is incorrect."; 233ca95b02SDimitry Andric case dia_error_code::already_loaded: 243ca95b02SDimitry Andric return "Unable to load the PDB or EXE, because it is already loaded."; 253ca95b02SDimitry Andric case dia_error_code::debug_info_mismatch: 263ca95b02SDimitry Andric return "The PDB file and the EXE file do not match."; 273ca95b02SDimitry Andric case dia_error_code::unspecified: 283ca95b02SDimitry Andric return "An unknown error has occurred."; 293ca95b02SDimitry Andric } 303ca95b02SDimitry Andric llvm_unreachable("Unrecognized DIAErrorCode"); 313ca95b02SDimitry Andric } 323ca95b02SDimitry Andric }; 333ca95b02SDimitry Andric 34*b5893f02SDimitry Andric static llvm::ManagedStatic<DIAErrorCategory> DIACategory; DIAErrCategory()35*b5893f02SDimitry Andricconst std::error_category &llvm::pdb::DIAErrCategory() { return *DIACategory; } 363ca95b02SDimitry Andric 37*b5893f02SDimitry Andric char DIAError::ID; 38