ObjFW
OFException.h
1 /*
2  * Copyright (c) 2008-2021 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #import "OFObject.h"
17 
18 #ifdef OF_WINDOWS
19 # include <windows.h>
20 #endif
21 
22 OF_ASSUME_NONNULL_BEGIN
23 
24 @class OFArray OF_GENERIC(ObjectType);
25 @class OFMutableArray OF_GENERIC(ObjectType);
26 @class OFString;
27 
28 #define OF_BACKTRACE_SIZE 16
29 
30 #if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS)
31 # ifndef EADDRINUSE
32 # define EADDRINUSE WSAEADDRINUSE
33 # endif
34 # ifndef EADDRNOTAVAIL
35 # define EADDRNOTAVAIL WSAEADDRNOTAVAIL
36 # endif
37 # ifndef EAFNOSUPPORT
38 # define EAFNOSUPPORT WSAEAFNOSUPPORT
39 # endif
40 # ifndef EALREADY
41 # define EALREADY WSAEALREADY
42 # endif
43 # ifndef ECONNABORTED
44 # define ECONNABORTED WSAECONNABORTED
45 # endif
46 # ifndef ECONNREFUSED
47 # define ECONNREFUSED WSAECONNREFUSED
48 # endif
49 # ifndef ECONNRESET
50 # define ECONNRESET WSAECONNRESET
51 # endif
52 # ifndef EDESTADDRREQ
53 # define EDESTADDRREQ WSAEDESTADDRREQ
54 # endif
55 # ifndef EDQUOT
56 # define EDQUOT WSAEDQUOT
57 # endif
58 # ifndef EHOSTDOWN
59 # define EHOSTDOWN WSAEHOSTDOWN
60 # endif
61 # ifndef EHOSTUNREACH
62 # define EHOSTUNREACH WSAEHOSTUNREACH
63 # endif
64 # ifndef EINPROGRESS
65 # define EINPROGRESS WSAEINPROGRESS
66 # endif
67 # ifndef EISCONN
68 # define EISCONN WSAEISCONN
69 # endif
70 # ifndef ELOOP
71 # define ELOOP WSAELOOP
72 # endif
73 # ifndef EMSGSIZE
74 # define EMSGSIZE WSAEMSGSIZE
75 # endif
76 # ifndef ENETDOWN
77 # define ENETDOWN WSAENETDOWN
78 # endif
79 # ifndef ENETRESET
80 # define ENETRESET WSAENETRESET
81 # endif
82 # ifndef ENETUNREACH
83 # define ENETUNREACH WSAENETUNREACH
84 # endif
85 # ifndef ENOBUFS
86 # define ENOBUFS WSAENOBUFS
87 # endif
88 # ifndef ENOPROTOOPT
89 # define ENOPROTOOPT WSAENOPROTOOPT
90 # endif
91 # ifndef ENOTCONN
92 # define ENOTCONN WSAENOTCONN
93 # endif
94 # ifndef ENOTSOCK
95 # define ENOTSOCK WSAENOTSOCK
96 # endif
97 # ifndef EOPNOTSUPP
98 # define EOPNOTSUPP WSAEOPNOTSUPP
99 # endif
100 # ifndef EPFNOSUPPORT
101 # define EPFNOSUPPORT WSAEPFNOSUPPORT
102 # endif
103 # ifndef EPROCLIM
104 # define EPROCLIM WSAEPROCLIM
105 # endif
106 # ifndef EPROTONOSUPPORT
107 # define EPROTONOSUPPORT WSAEPROTONOSUPPORT
108 # endif
109 # ifndef EPROTOTYPE
110 # define EPROTOTYPE WSAEPROTOTYPE
111 # endif
112 # ifndef EREMOTE
113 # define EREMOTE WSAEREMOTE
114 # endif
115 # ifndef ESHUTDOWN
116 # define ESHUTDOWN WSAESHUTDOWN
117 # endif
118 # ifndef ESOCKTNOSUPPORT
119 # define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
120 # endif
121 # ifndef ESTALE
122 # define ESTALE WSAESTALE
123 # endif
124 # ifndef ETIMEDOUT
125 # define ETIMEDOUT WSAETIMEDOUT
126 # endif
127 # ifndef ETOOMANYREFS
128 # define ETOOMANYREFS WSAETOOMANYREFS
129 # endif
130 # ifndef EUSERS
131 # define EUSERS WSAEUSERS
132 # endif
133 # ifndef EWOULDBLOCK
134 # define EWOULDBLOCK WSAEWOULDBLOCK
135 # endif
136 #endif
137 
147 {
148  void *_backtrace[OF_BACKTRACE_SIZE];
149 }
150 
156 + (instancetype)exception;
157 
163 - (OFString *)description;
164 
171 - (nullable OFArray OF_GENERIC(OFString *) *)backtrace;
172 @end
173 
174 #ifdef __cplusplus
175 extern "C" {
176 #endif
177 extern OFString *of_strerror(int errNo);
178 #ifdef OF_WINDOWS
179 extern OFString *of_windows_status_to_string(LSTATUS status);
180 #endif
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:92
The base class for all exceptions in ObjFW.
Definition: OFException.h:147
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:44
The root class for all other classes inside ObjFW.
Definition: OFObject.h:520
A class for handling strings.
Definition: OFString.h:132