1 module hunt.http.Exceptions;
2
3 import hunt.http.WebSocketStatusCode;
4 import hunt.Exceptions;
5
6
7
8 /**
9 *
10 */
11 class SessionInvalidException : RuntimeException {
12 mixin BasicExceptionCtors;
13 }
14
15 /**
16 *
17 */
18 class SessionNotFoundException : RuntimeException {
19 mixin BasicExceptionCtors;
20 }
21
22
23
24 class WebSocketException : RuntimeException
25 {
26 mixin BasicExceptionCtors;
27 }
28
29 class CloseException : WebSocketException
30 {
31 private int statusCode;
32
33 this(int closeCode, string message, size_t line = __LINE__, string file = __FILE__) {
34 super(message);
35 this.statusCode = closeCode;
36 }
37
38 this(int closeCode, string message, Throwable cause, size_t line = __LINE__, string file = __FILE__) {
39 super(message, cause);
40 this.statusCode = closeCode;
41 }
42
43 this(int closeCode, Throwable cause, size_t line = __LINE__, string file = __FILE__) {
44 super(cause);
45 this.statusCode = closeCode;
46 }
47
48 int getStatusCode() {
49 return statusCode;
50 }
51
52 }
53
54 class BadPayloadException : CloseException
55 {
56 this(string message, size_t line = __LINE__, string file = __FILE__) {
57 super(StatusCode.BAD_PAYLOAD, message, line, file);
58 }
59
60 this(string message, Throwable t, size_t line = __LINE__, string file = __FILE__) {
61 super(StatusCode.BAD_PAYLOAD, message, t, line, file);
62 }
63
64 this(Throwable t, size_t line = __LINE__, string file = __FILE__) {
65 super(StatusCode.BAD_PAYLOAD, t, line, file);
66 }
67 }
68
69 class MessageTooLargeException : CloseException
70 {
71 this(string message, size_t line = __LINE__, string file = __FILE__) {
72 super(StatusCode.MESSAGE_TOO_LARGE, message, line, file);
73 }
74
75 this(string message, Throwable t, size_t line = __LINE__, string file = __FILE__) {
76 super(StatusCode.MESSAGE_TOO_LARGE, message, t, line, file);
77 }
78
79 this(Throwable t, size_t line = __LINE__, string file = __FILE__) {
80 super(StatusCode.MESSAGE_TOO_LARGE, t, line, file);
81 }
82 }
83
84 class ProtocolException : CloseException
85 {
86 this(string message, size_t line = __LINE__, string file = __FILE__) {
87 super(StatusCode.PROTOCOL, message, line, file);
88 }
89
90 this(string message, Throwable t, size_t line = __LINE__, string file = __FILE__) {
91 super(StatusCode.PROTOCOL, message, t, line, file);
92 }
93
94 this(Throwable t, size_t line = __LINE__, string file = __FILE__) {
95 super(StatusCode.PROTOCOL, t, line, file);
96 }
97 }