1*0b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAError.h" 2*0b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h" 3*0b57cec5SDimitry Andric #include "llvm/Support/ManagedStatic.h" 4*0b57cec5SDimitry Andric 5*0b57cec5SDimitry Andric using namespace llvm; 6*0b57cec5SDimitry Andric using namespace llvm::pdb; 7*0b57cec5SDimitry Andric 8*0b57cec5SDimitry Andric // FIXME: This class is only here to support the transition to llvm::Error. It 9*0b57cec5SDimitry Andric // will be removed once this transition is complete. Clients should prefer to 10*0b57cec5SDimitry Andric // deal with the Error value directly, rather than converting to error_code. 11*0b57cec5SDimitry Andric class DIAErrorCategory : public std::error_category { 12*0b57cec5SDimitry Andric public: name() const13*0b57cec5SDimitry Andric const char *name() const noexcept override { return "llvm.pdb.dia"; } message(int Condition) const14*0b57cec5SDimitry Andric std::string message(int Condition) const override { 15*0b57cec5SDimitry Andric switch (static_cast<dia_error_code>(Condition)) { 16*0b57cec5SDimitry Andric case dia_error_code::could_not_create_impl: 17*0b57cec5SDimitry Andric return "Failed to connect to DIA at runtime. Verify that Visual Studio " 18*0b57cec5SDimitry Andric "is properly installed, or that msdiaXX.dll is in your PATH."; 19*0b57cec5SDimitry Andric case dia_error_code::invalid_file_format: 20*0b57cec5SDimitry Andric return "Unable to load PDB. The file has an unrecognized format."; 21*0b57cec5SDimitry Andric case dia_error_code::invalid_parameter: 22*0b57cec5SDimitry Andric return "The parameter is incorrect."; 23*0b57cec5SDimitry Andric case dia_error_code::already_loaded: 24*0b57cec5SDimitry Andric return "Unable to load the PDB or EXE, because it is already loaded."; 25*0b57cec5SDimitry Andric case dia_error_code::debug_info_mismatch: 26*0b57cec5SDimitry Andric return "The PDB file and the EXE file do not match."; 27*0b57cec5SDimitry Andric case dia_error_code::unspecified: 28*0b57cec5SDimitry Andric return "An unknown error has occurred."; 29*0b57cec5SDimitry Andric } 30*0b57cec5SDimitry Andric llvm_unreachable("Unrecognized DIAErrorCode"); 31*0b57cec5SDimitry Andric } 32*0b57cec5SDimitry Andric }; 33*0b57cec5SDimitry Andric 34*0b57cec5SDimitry Andric static llvm::ManagedStatic<DIAErrorCategory> DIACategory; DIAErrCategory()35*0b57cec5SDimitry Andricconst std::error_category &llvm::pdb::DIAErrCategory() { return *DIACategory; } 36*0b57cec5SDimitry Andric 37*0b57cec5SDimitry Andric char DIAError::ID; 38