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