17#ifndef LIB_ERROR_CATALOG_H_ 
   18#define LIB_ERROR_CATALOG_H_ 
   24#include "lib/error_message.h" 
   25#include "lib/exceptions.h" 
   27using MessageType = ErrorMessage::MessageType;
 
   36    static const int LEGACY_ERROR;
 
   37    static const int ERR_UNKNOWN;                
 
   38    static const int ERR_UNSUPPORTED;            
 
   39    static const int ERR_UNEXPECTED;             
 
   40    static const int ERR_UNINITIALIZED;          
 
   41    static const int ERR_EXPECTED;               
 
   42    static const int ERR_NOT_FOUND;              
 
   43    static const int ERR_INVALID;                
 
   44    static const int ERR_EXPRESSION;             
 
   45    static const int ERR_OVERLIMIT;              
 
   46    static const int ERR_INSUFFICIENT;           
 
   47    static const int ERR_TYPE_ERROR;             
 
   48    static const int ERR_UNSUPPORTED_ON_TARGET;  
 
   49    static const int ERR_DUPLICATE;              
 
   50    static const int ERR_IO;                     
 
   51    static const int ERR_UNREACHABLE;            
 
   52    static const int ERR_MODEL;                  
 
   53    static const int ERR_RESERVED;               
 
   55    static const int ERR_MIN_BACKEND = 500;  
 
   56    static const int ERR_MAX = 999;          
 
   60    static const int LEGACY_WARNING;
 
   61    static const int WARN_FAILED;                   
 
   62    static const int WARN_UNKNOWN;                  
 
   63    static const int WARN_INVALID;                  
 
   64    static const int WARN_UNSUPPORTED;              
 
   65    static const int WARN_DEPRECATED;               
 
   66    static const int WARN_UNINITIALIZED;            
 
   67    static const int WARN_UNINITIALIZED_USE;        
 
   68    static const int WARN_UNINITIALIZED_OUT_PARAM;  
 
   69    static const int WARN_UNUSED;                   
 
   70    static const int WARN_MISSING;                  
 
   71    static const int WARN_ORDERING;                 
 
   72    static const int WARN_MISMATCH;                 
 
   73    static const int WARN_OVERFLOW;                 
 
   74    static const int WARN_IGNORE_PROPERTY;          
 
   75    static const int WARN_TYPE_INFERENCE;           
 
   76    static const int WARN_PARSER_TRANSITION;        
 
   77    static const int WARN_UNREACHABLE;              
 
   78    static const int WARN_SHADOWING;                
 
   79    static const int WARN_IGNORE;                   
 
   80    static const int WARN_INVALID_HEADER;           
 
   81    static const int WARN_DUPLICATE_PRIORITIES;     
 
   82    static const int WARN_ENTRIES_OUT_OF_ORDER;     
 
   83    static const int WARN_MULTI_HDR_EXTRACT;        
 
   85    static const int WARN_MIN_BACKEND = 1500;  
 
   86    static const int WARN_MAX = 2141;          
 
   90    static const int INFO_INFERRED;  
 
   91    static const int INFO_PROGRESS;  
 
   94    static const int INFO_MIN_BACKEND = 3000;  
 
   95    static const int INFO_MAX = 3999;          
 
 
  112    template <MessageType type, 
int errorCode>
 
  113    bool add(
const char *name, 
bool forceReplace = 
false) {
 
  114        static_assert(type != MessageType::Error ||
 
  115                      (errorCode >= ErrorType::ERR_MIN_BACKEND && errorCode <= ErrorType::ERR_MAX));
 
  116        static_assert(type != MessageType::Warning || (errorCode >= ErrorType::WARN_MIN_BACKEND &&
 
  117                                                       errorCode <= ErrorType::WARN_MAX));
 
  118        static_assert(type != MessageType::Info || (errorCode >= ErrorType::INFO_MIN_BACKEND &&
 
  119                                                    errorCode <= ErrorType::INFO_MAX));
 
  120        static_assert(type != MessageType::None);
 
  121        if (forceReplace) errorCatalog.erase(errorCode);
 
  122        auto it = errorCatalog.emplace(errorCode, name);
 
 
  130        if (errorCatalog.count(errorCode)) 
return errorCatalog.at(errorCode);
 
  131        return "--unknown--"_cs;
 
 
  140        for (
const auto &pair : errorCatalog) {
 
  141            if (pair.second == lookup) {
 
  142                if (pair.first < ErrorType::LEGACY_ERROR || pair.first > ErrorType::ERR_MAX)
 
 
  155    static std::map<int, cstring> errorCatalog;
 
 
Definition error_catalog.h:98
 
cstring getName(int errorCode)
retrieve the name for errorCode
Definition error_catalog.h:127
 
bool add(const char *name, bool forceReplace=false)
Definition error_catalog.h:113
 
bool isError(std::string_view name)
return true if the given diagnostic can only be an error; false otherwise
Definition error_catalog.h:135
 
static ErrorCatalog & getCatalog()
Return the singleton object.
Definition error_catalog.h:101
 
Definition error_catalog.h:31