61class P4CExceptionBase :
public std::exception {
64 void traceCreation() {}
67 template <
typename... Args>
68 explicit P4CExceptionBase(
const char *format, Args &&...args) {
70 boost::format fmt(format);
73 message = ::P4::bug_helper(fmt,
"",
"", std::forward<Args>(args)...);
76 const char *what()
const noexcept override {
return message.c_str(); }
80class CompilerBug final :
public P4CExceptionBase {
82 template <
typename... Args>
83 explicit CompilerBug(
const char *format, Args &&...args)
84 : P4CExceptionBase(format, std::forward<Args>(args)...) {
87 message = absl::StrCat(cerr_colorize(ANSI_RED),
"Compiler Bug", cerr_clear_colors(),
":\n",
91 template <
typename... Args>
92 CompilerBug(
int line,
const char *file,
const char *format, Args &&...args)
93 : P4CExceptionBase(format, std::forward<Args>(args)...) {
94 message = absl::StrCat(
"In file: ", file,
":", line,
"\n", cerr_colorize(ANSI_RED),
95 "Compiler Bug", cerr_clear_colors(),
": ", message);
100class CompilerUnimplemented final :
public P4CExceptionBase {
102 template <
typename... Args>
103 explicit CompilerUnimplemented(
const char *format, Args &&...args)
104 : P4CExceptionBase(format, std::forward<Args>(args)...) {
106 message = absl::StrCat(cerr_colorize(ANSI_BLUE),
"Not yet implemented", cerr_clear_colors(),
110 template <
typename... Args>
111 CompilerUnimplemented(
int line,
const char *file,
const char *format, Args &&...args)
112 : P4CExceptionBase(format, std::forward<Args>(args)...) {
114 absl::StrCat(
"In file: ", file,
":", line,
"\n", cerr_colorize(ANSI_BLUE),
115 "Unimplemented compiler support", cerr_clear_colors(),
": ", message);