70class P4CExceptionBase :
public std::exception {
73 void traceCreation() {}
76 template <
typename... Args>
77 explicit P4CExceptionBase(
const char *format, Args &&...args) {
79 boost::format fmt(format);
82 message = ::P4::bug_helper(fmt,
"",
"", std::forward<Args>(args)...);
85 const char *what()
const noexcept {
return message.c_str(); }
89class CompilerBug final :
public P4CExceptionBase {
91 template <
typename... Args>
92 explicit CompilerBug(
const char *format, Args &&...args)
93 : P4CExceptionBase(format, std::forward<Args>(args)...) {
96 message = absl::StrCat(cerr_colorize(ANSI_RED),
"Compiler Bug", cerr_clear_colors(),
":\n",
100 template <
typename... Args>
101 CompilerBug(
int line,
const char *file,
const char *format, Args &&...args)
102 : P4CExceptionBase(format, std::forward<Args>(args)...) {
103 message = absl::StrCat(
"In file: ", file,
":", line,
"\n", cerr_colorize(ANSI_RED),
104 "Compiler Bug", cerr_clear_colors(),
": ", message);
109class CompilerUnimplemented final :
public P4CExceptionBase {
111 template <
typename... Args>
112 explicit CompilerUnimplemented(
const char *format, Args &&...args)
113 : P4CExceptionBase(format, std::forward<Args>(args)...) {
115 message = absl::StrCat(cerr_colorize(ANSI_BLUE),
"Not yet implemented", cerr_clear_colors(),
119 template <
typename... Args>
120 CompilerUnimplemented(
int line,
const char *file,
const char *format, Args &&...args)
121 : P4CExceptionBase(format, std::forward<Args>(args)...) {
123 absl::StrCat(
"In file: ", file,
":", line,
"\n", cerr_colorize(ANSI_BLUE),
124 "Unimplemented compiler support", cerr_clear_colors(),
": ", message);