1 /*******************************************************************************
2  * Exceptions used by the D protocol buffer system
3  *
4  * Authors: Matthew Soucy, dproto@msoucy.me
5  */
6 module dproto.exception;
7 import std.exception;
8 
9 /// Basic exception, something went wrong with creating a buffer struct
10 class DProtoException : Exception {
11 	static if (__traits(compiles, {mixin basicExceptionCtors;})) {
12 		///
13 		mixin basicExceptionCtors;
14 	} else {
15 		this(string msg, string file = __FILE__, size_t line = __LINE__,
16 			 Throwable next = null) @safe pure nothrow {
17 			super(msg, file, line, next);
18 		}
19 
20 		this(string msg, Throwable next, string file = __FILE__,
21 			 size_t line = __LINE__) @safe pure nothrow {
22 			super(msg, file, line, next);
23 		}
24 	}
25 }
26 
27 /// Proto file attempted to use a reserved word
28 class DProtoReservedWordException : DProtoException {
29 	static if (__traits(compiles, {mixin basicExceptionCtors;})) {
30 		///
31 		mixin basicExceptionCtors;
32 	} else {
33 		this(string msg, string file = __FILE__, size_t line = __LINE__,
34 			 Throwable next = null) @safe pure nothrow {
35 			super(msg, file, line, next);
36 		}
37 
38 		this(string msg, Throwable next, string file = __FILE__,
39 			 size_t line = __LINE__) @safe pure nothrow {
40 			super(msg, file, line, next);
41 		}
42 	}
43 }
44 
45 /// Proto file used invalid syntax
46 class DProtoSyntaxException : DProtoException {
47 	static if (__traits(compiles, {mixin basicExceptionCtors;})) {
48 		///
49 		mixin basicExceptionCtors;
50 	} else {
51 		this(string msg, string file = __FILE__, size_t line = __LINE__,
52 			 Throwable next = null) @safe pure nothrow {
53 			super(msg, file, line, next);
54 		}
55 
56 		this(string msg, Throwable next, string file = __FILE__,
57 			 size_t line = __LINE__) @safe pure nothrow {
58 			super(msg, file, line, next);
59 		}
60 	}
61 }