MushOS  0.1
A UNIX-like OS prototype, written from scratch
Loading...
Searching...
No Matches
exceptions.h
1#ifndef MUSHLIB_EXCEPTIONS_H
2#define MUSHLIB_EXCEPTIONS_H
3
4#include "generic.h"
5
6
7typedef struct {
8 u_byte id;
9 string type;
10 string message;
11 string file;
12 u_dword line;
13} exception;
14
15typedef void (*exception_handler)(exception exc);
16
17void throw_exception(exception exc);
18void handle_exceptions(u_byte id, exception_handler);
19
20void terminate(u_byte code);
21
22#define throw_verbose(id, type, message) {\
23 exception exc = {id, type, message, __FILE__, __LINE__};\
24 throw_exception(exc);\
25}
26
27#define throw_typed(id, type) throw_verbose(id, type, nullptr)
28
29#define throw(id) throw_typed(id, nullptr)
30
31#endif // MUSHLIB_EXCEPTIONS_H