custom_exception.h


1
#ifndef CUSTOM_EXCEPTION_H
2
#define CUSTOM_EXCEPTION_H
3
4
#include "exception.h"
5
6
#define EXCEPTION_ANY( T ) struct T ## _type T;
7
#define EXCEPTION_TYPES( T ) T,
8
9
10
#define EXCEPTION( X ) \
11
  X(test_exception)
12
13
14
struct test_exception_type {
15
  struct exception base;
16
  const char* message;
17
};
18
19
union anyException {
20
  EXCEPTION( EXCEPTION_ANY )
21
};
22
23
enum exceptionType {
24
  EXCEPTION( EXCEPTION_TYPES )
25
  EXCEPTION_COUNT
26
};
27
28
#endif