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;
35 static const int LEGACY_ERROR;
36 static const int ERR_UNKNOWN;
37 static const int ERR_UNSUPPORTED;
38 static const int ERR_UNEXPECTED;
39 static const int ERR_UNINITIALIZED;
40 static const int ERR_EXPECTED;
41 static const int ERR_NOT_FOUND;
42 static const int ERR_INVALID;
43 static const int ERR_EXPRESSION;
44 static const int ERR_OVERLIMIT;
45 static const int ERR_INSUFFICIENT;
46 static const int ERR_TYPE_ERROR;
47 static const int ERR_UNSUPPORTED_ON_TARGET;
48 static const int ERR_DUPLICATE;
49 static const int ERR_IO;
50 static const int ERR_UNREACHABLE;
51 static const int ERR_MODEL;
52 static const int ERR_RESERVED;
54 static const int ERR_MIN_BACKEND = 500;
55 static const int ERR_MAX = 999;
59 static const int LEGACY_WARNING;
60 static const int WARN_FAILED;
61 static const int WARN_UNKNOWN;
62 static const int WARN_INVALID;
63 static const int WARN_UNSUPPORTED;
64 static const int WARN_DEPRECATED;
65 static const int WARN_UNINITIALIZED;
66 static const int WARN_UNINITIALIZED_USE;
67 static const int WARN_UNINITIALIZED_OUT_PARAM;
68 static const int WARN_UNUSED;
69 static const int WARN_MISSING;
70 static const int WARN_ORDERING;
71 static const int WARN_MISMATCH;
72 static const int WARN_OVERFLOW;
73 static const int WARN_IGNORE_PROPERTY;
74 static const int WARN_TYPE_INFERENCE;
75 static const int WARN_PARSER_TRANSITION;
76 static const int WARN_UNREACHABLE;
77 static const int WARN_SHADOWING;
78 static const int WARN_IGNORE;
79 static const int WARN_INVALID_HEADER;
80 static const int WARN_DUPLICATE_PRIORITIES;
81 static const int WARN_ENTRIES_OUT_OF_ORDER;
83 static const int WARN_MIN_BACKEND = 1500;
84 static const int WARN_MAX = 2141;
88 static const int INFO_INFERRED;
89 static const int INFO_PROGRESS;
92 static const int INFO_MIN_BACKEND = 3000;
93 static const int INFO_MAX = 3999;
110 template <MessageType type,
int errorCode>
111 bool add(
const char *name,
bool forceReplace =
false) {
112 static_assert(type != MessageType::Error ||
113 (errorCode >= ErrorType::ERR_MIN_BACKEND && errorCode <= ErrorType::ERR_MAX));
114 static_assert(type != MessageType::Warning || (errorCode >= ErrorType::WARN_MIN_BACKEND &&
115 errorCode <= ErrorType::WARN_MAX));
116 static_assert(type != MessageType::Info || (errorCode >= ErrorType::INFO_MIN_BACKEND &&
117 errorCode <= ErrorType::INFO_MAX));
118 static_assert(type != MessageType::None);
119 if (forceReplace) errorCatalog.erase(errorCode);
120 auto it = errorCatalog.emplace(errorCode, name);
126 if (errorCatalog.count(errorCode))
return errorCatalog.at(errorCode);
127 return "--unknown--";
135 for (
const auto &pair : errorCatalog) {
136 if (pair.second == name) {
137 if (pair.first < ErrorType::LEGACY_ERROR || pair.first > ErrorType::ERR_MAX)
150 static std::map<int, cstring> errorCatalog;
Definition error_catalog.h:96
cstring getName(int errorCode)
retrieve the name for errorCode
Definition error_catalog.h:125
bool isError(cstring name)
return true if the given diagnostic can only be an error; false otherwise
Definition error_catalog.h:131
bool add(const char *name, bool forceReplace=false)
Definition error_catalog.h:111
static ErrorCatalog & getCatalog()
Return the singleton object.
Definition error_catalog.h:99
Definition error_catalog.h:31