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