xref: /freebsd-src/contrib/llvm-project/llvm/lib/DebugInfo/PDB/DIA/DIAError.cpp (revision 753f127f3ace09432b2baeffd71a308760641a62)
10b57cec5SDimitry Andric #include "llvm/DebugInfo/PDB/DIA/DIAError.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 // FIXME: This class is only here to support the transition to llvm::Error. It
80b57cec5SDimitry Andric // will be removed once this transition is complete. Clients should prefer to
90b57cec5SDimitry Andric // deal with the Error value directly, rather than converting to error_code.
100b57cec5SDimitry Andric class DIAErrorCategory : public std::error_category {
110b57cec5SDimitry Andric public:
name() const120b57cec5SDimitry Andric   const char *name() const noexcept override { return "llvm.pdb.dia"; }
message(int Condition) const130b57cec5SDimitry Andric   std::string message(int Condition) const override {
140b57cec5SDimitry Andric     switch (static_cast<dia_error_code>(Condition)) {
150b57cec5SDimitry Andric     case dia_error_code::could_not_create_impl:
160b57cec5SDimitry Andric       return "Failed to connect to DIA at runtime. Verify that Visual Studio "
170b57cec5SDimitry Andric              "is properly installed, or that msdiaXX.dll is in your PATH.";
180b57cec5SDimitry Andric     case dia_error_code::invalid_file_format:
190b57cec5SDimitry Andric       return "Unable to load PDB. The file has an unrecognized format.";
200b57cec5SDimitry Andric     case dia_error_code::invalid_parameter:
210b57cec5SDimitry Andric       return "The parameter is incorrect.";
220b57cec5SDimitry Andric     case dia_error_code::already_loaded:
230b57cec5SDimitry Andric       return "Unable to load the PDB or EXE, because it is already loaded.";
240b57cec5SDimitry Andric     case dia_error_code::debug_info_mismatch:
250b57cec5SDimitry Andric       return "The PDB file and the EXE file do not match.";
260b57cec5SDimitry Andric     case dia_error_code::unspecified:
270b57cec5SDimitry Andric       return "An unknown error has occurred.";
280b57cec5SDimitry Andric     }
290b57cec5SDimitry Andric     llvm_unreachable("Unrecognized DIAErrorCode");
300b57cec5SDimitry Andric   }
310b57cec5SDimitry Andric };
320b57cec5SDimitry Andric 
DIAErrCategory()33*753f127fSDimitry Andric const std::error_category &llvm::pdb::DIAErrCategory() {
34*753f127fSDimitry Andric   static DIAErrorCategory DIACategory;
35*753f127fSDimitry Andric   return DIACategory;
36*753f127fSDimitry Andric }
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric char DIAError::ID;
39