P4C
The P4 Compiler
Loading...
Searching...
No Matches
backends/p4tools/modules/testgen/lib/exceptions.h
1#ifndef BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_EXCEPTIONS_H_
2#define BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_EXCEPTIONS_H_
3
4#include "absl/strings/str_cat.h"
5#include "lib/exceptions.h"
6
7namespace P4::P4Tools::P4Testgen {
8
12 public:
13 template <typename... Args>
14 explicit TestgenUnimplemented(const char *format, Args &&...args)
15 : P4CExceptionBase(format, std::forward<Args>(args)...) {
16 // Check if output is redirected and if so, then don't color text so that
17 // escape characters are not present
18 message = absl::StrCat(Util::cerr_colorize(Util::ANSI_BLUE), "Not yet implemented",
19 Util::cerr_clear_colors(), ":\n", message);
20 }
21
22 template <typename... Args>
23 TestgenUnimplemented(int line, const char *file, const char *format, Args &&...args)
24 : P4CExceptionBase(format, std::forward<Args>(args)...) {
25 message = absl::StrCat(
26 "In file: ", file, ":", line, "\n", Util::cerr_colorize(Util::ANSI_BLUE),
27 "Unimplemented compiler support", Util::cerr_clear_colors(), ": ", message);
28 }
29};
30
31#define TESTGEN_UNIMPLEMENTED(...) \
32 do { \
33 throw TestgenUnimplemented(__LINE__, __FILE__, __VA_ARGS__); \
34 } while (0)
35
36} // namespace P4::P4Tools::P4Testgen
37
38#endif /* BACKENDS_P4TOOLS_MODULES_TESTGEN_LIB_EXCEPTIONS_H_ */
Definition backends/p4tools/modules/testgen/lib/exceptions.h:11
Definition lib/exceptions.h:70