-
Notifications
You must be signed in to change notification settings - Fork 1
/
exceptions.h
38 lines (31 loc) · 1.16 KB
/
exceptions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef LATTE_EXCEPTIONS_H
#define LATTE_EXCEPTIONS_H
#include <exception>
/*
* Custom exception classes used in Latte compiler.
* */
class LatteException : public std::exception
{
public:
LatteException () throw() {}
LatteException (const LatteException&) throw(): std::exception() {}
LatteException& operator= (const LatteException&) throw() {return *this;}
virtual ~LatteException() throw() {}
virtual const char* what() const throw() = 0;
};
#define LATTE_EXCEPTION(NAME) \
class NAME : public LatteException \
{ \
public: \
NAME() throw() {} \
NAME(const NAME& ex __attribute__((__unused__))) throw() : LatteException() {} \
~NAME() throw() {} \
const char* what() const throw(){ \
return "Latte: " #NAME ; \
} \
}
LATTE_EXCEPTION(InternalErrorException);
LATTE_EXCEPTION(NotImplementedException);
LATTE_EXCEPTION(IdentifierNotFoundException);
LATTE_EXCEPTION(IdentifierRepeatedException);
#endif //LATTE_EXCEPTIONS_H