ObjFW
OFException.h
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3.0 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * version 3.0 for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * version 3.0 along with this program. If not, see
17  * <https://www.gnu.org/licenses/>.
18  */
19 
20 #import "OFObject.h"
21 
22 #ifdef OF_WINDOWS
23 # include <windows.h>
24 #endif
25 
26 OF_ASSUME_NONNULL_BEGIN
27 
28 @class OFArray OF_GENERIC(ObjectType);
29 @class OFString;
30 @class OFValue;
31 
32 #define OFStackTraceSize 16
33 
34 #if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS)
35 # ifndef EADDRINUSE
36 # define EADDRINUSE WSAEADDRINUSE
37 # endif
38 # ifndef EADDRNOTAVAIL
39 # define EADDRNOTAVAIL WSAEADDRNOTAVAIL
40 # endif
41 # ifndef EAFNOSUPPORT
42 # define EAFNOSUPPORT WSAEAFNOSUPPORT
43 # endif
44 # ifndef EALREADY
45 # define EALREADY WSAEALREADY
46 # endif
47 # ifndef ECONNABORTED
48 # define ECONNABORTED WSAECONNABORTED
49 # endif
50 # ifndef ECONNREFUSED
51 # define ECONNREFUSED WSAECONNREFUSED
52 # endif
53 # ifndef ECONNRESET
54 # define ECONNRESET WSAECONNRESET
55 # endif
56 # ifndef EDESTADDRREQ
57 # define EDESTADDRREQ WSAEDESTADDRREQ
58 # endif
59 # ifndef EDQUOT
60 # define EDQUOT WSAEDQUOT
61 # endif
62 # ifndef EHOSTDOWN
63 # define EHOSTDOWN WSAEHOSTDOWN
64 # endif
65 # ifndef EHOSTUNREACH
66 # define EHOSTUNREACH WSAEHOSTUNREACH
67 # endif
68 # ifndef EINPROGRESS
69 # define EINPROGRESS WSAEINPROGRESS
70 # endif
71 # ifndef EISCONN
72 # define EISCONN WSAEISCONN
73 # endif
74 # ifndef ELOOP
75 # define ELOOP WSAELOOP
76 # endif
77 # ifndef EMSGSIZE
78 # define EMSGSIZE WSAEMSGSIZE
79 # endif
80 # ifndef ENETDOWN
81 # define ENETDOWN WSAENETDOWN
82 # endif
83 # ifndef ENETRESET
84 # define ENETRESET WSAENETRESET
85 # endif
86 # ifndef ENETUNREACH
87 # define ENETUNREACH WSAENETUNREACH
88 # endif
89 # ifndef ENOBUFS
90 # define ENOBUFS WSAENOBUFS
91 # endif
92 # ifndef ENOPROTOOPT
93 # define ENOPROTOOPT WSAENOPROTOOPT
94 # endif
95 # ifndef ENOTCONN
96 # define ENOTCONN WSAENOTCONN
97 # endif
98 # ifndef ENOTSOCK
99 # define ENOTSOCK WSAENOTSOCK
100 # endif
101 # ifndef EOPNOTSUPP
102 # define EOPNOTSUPP WSAEOPNOTSUPP
103 # endif
104 # ifndef EPFNOSUPPORT
105 # define EPFNOSUPPORT WSAEPFNOSUPPORT
106 # endif
107 # ifndef EPROCLIM
108 # define EPROCLIM WSAEPROCLIM
109 # endif
110 # ifndef EPROTONOSUPPORT
111 # define EPROTONOSUPPORT WSAEPROTONOSUPPORT
112 # endif
113 # ifndef EPROTOTYPE
114 # define EPROTOTYPE WSAEPROTOTYPE
115 # endif
116 # ifndef EREMOTE
117 # define EREMOTE WSAEREMOTE
118 # endif
119 # ifndef ESHUTDOWN
120 # define ESHUTDOWN WSAESHUTDOWN
121 # endif
122 # ifndef ESOCKTNOSUPPORT
123 # define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
124 # endif
125 # ifndef ESTALE
126 # define ESTALE WSAESTALE
127 # endif
128 # ifndef ETIMEDOUT
129 # define ETIMEDOUT WSAETIMEDOUT
130 # endif
131 # ifndef ETOOMANYREFS
132 # define ETOOMANYREFS WSAETOOMANYREFS
133 # endif
134 # ifndef EUSERS
135 # define EUSERS WSAEUSERS
136 # endif
137 # ifndef EWOULDBLOCK
138 # define EWOULDBLOCK WSAEWOULDBLOCK
139 # endif
140 #endif
141 
142 #ifndef EWOULDBLOCK
143 # define EWOULDBLOCK EAGAIN
144 #endif
145 
155 {
156  void *_stackTrace[OFStackTraceSize];
157  OF_RESERVE_IVARS(OFException, 4)
158 }
159 
165 + (instancetype)exception;
166 
172 - (OFString *)description;
173 
181 - (nullable OFArray OF_GENERIC(OFValue *) *)stackTraceAddresses;
182 
189 - (nullable OFArray OF_GENERIC(OFString *) *)stackTraceSymbols;
190 @end
191 
192 #ifdef __cplusplus
193 extern "C" {
194 #endif
195 extern OFString *OFStrError(int errNo);
196 #ifdef OF_WINDOWS
197 extern OFString *OFWindowsStatusToString(LSTATUS status);
198 #endif
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 OF_ASSUME_NONNULL_END
An abstract class for storing objects in an array.
Definition: OFArray.h:109
The base class for all exceptions in ObjFW.
Definition: OFException.h:155
The root class for all other classes inside ObjFW.
Definition: OFObject.h:692
A class for handling strings.
Definition: OFString.h:139
A class for storing arbitrary values in an object.
Definition: OFValue.h:29