xref: /haiku/headers/os/support/Errors.h (revision f75a7bf508f3156d63a14f8fd77c5e0ca4d08c42)
1 /*
2  * Copyright 2007, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _ERRORS_H
6 #define _ERRORS_H
7 
8 
9 #include <limits.h>
10 
11 
12 /* Error baselines */
13 #define B_GENERAL_ERROR_BASE		LONG_MIN
14 #define B_OS_ERROR_BASE				(B_GENERAL_ERROR_BASE + 0x1000)
15 #define B_APP_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x2000)
16 #define B_INTERFACE_ERROR_BASE		(B_GENERAL_ERROR_BASE + 0x3000)
17 #define B_MEDIA_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x4000)
18 										/* - 0x41ff */
19 #define B_TRANSLATION_ERROR_BASE	(B_GENERAL_ERROR_BASE + 0x4800)
20 										/* - 0x48ff */
21 #define B_MIDI_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x5000)
22 #define B_STORAGE_ERROR_BASE		(B_GENERAL_ERROR_BASE + 0x6000)
23 #define B_POSIX_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x7000)
24 #define B_MAIL_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x8000)
25 #define B_PRINT_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0x9000)
26 #define B_DEVICE_ERROR_BASE			(B_GENERAL_ERROR_BASE + 0xa000)
27 
28 /* Developer-defined errors start at (B_ERRORS_END+1) */
29 #define B_ERRORS_END				(B_GENERAL_ERROR_BASE + 0xffff)
30 
31 /* General Errors */
32 #define B_NO_MEMORY					(B_GENERAL_ERROR_BASE + 0)
33 #define B_IO_ERROR					(B_GENERAL_ERROR_BASE + 1)
34 #define B_PERMISSION_DENIED			(B_GENERAL_ERROR_BASE + 2)
35 #define B_BAD_INDEX					(B_GENERAL_ERROR_BASE + 3)
36 #define B_BAD_TYPE					(B_GENERAL_ERROR_BASE + 4)
37 #define B_BAD_VALUE					(B_GENERAL_ERROR_BASE + 5)
38 #define B_MISMATCHED_VALUES			(B_GENERAL_ERROR_BASE + 6)
39 #define B_NAME_NOT_FOUND			(B_GENERAL_ERROR_BASE + 7)
40 #define B_NAME_IN_USE				(B_GENERAL_ERROR_BASE + 8)
41 #define B_TIMED_OUT					(B_GENERAL_ERROR_BASE + 9)
42 #define B_INTERRUPTED				(B_GENERAL_ERROR_BASE + 10)
43 #define B_WOULD_BLOCK				(B_GENERAL_ERROR_BASE + 11)
44 #define B_CANCELED					(B_GENERAL_ERROR_BASE + 12)
45 #define B_NO_INIT					(B_GENERAL_ERROR_BASE + 13)
46 #define B_BUSY						(B_GENERAL_ERROR_BASE + 14)
47 #define B_NOT_ALLOWED				(B_GENERAL_ERROR_BASE + 15)
48 #define B_BAD_DATA					(B_GENERAL_ERROR_BASE + 16)
49 #define B_DONT_DO_THAT				(B_GENERAL_ERROR_BASE + 17)
50 
51 #define B_ERROR						(-1)
52 #define B_OK						((int)0)
53 #define B_NO_ERROR					((int)0)
54 
55 /* Kernel Kit Errors */
56 #define B_BAD_SEM_ID				(B_OS_ERROR_BASE + 0)
57 #define B_NO_MORE_SEMS				(B_OS_ERROR_BASE + 1)
58 
59 #define B_BAD_THREAD_ID				(B_OS_ERROR_BASE + 0x100)
60 #define B_NO_MORE_THREADS			(B_OS_ERROR_BASE + 0x101)
61 #define B_BAD_THREAD_STATE			(B_OS_ERROR_BASE + 0x102)
62 #define B_BAD_TEAM_ID				(B_OS_ERROR_BASE + 0x103)
63 #define B_NO_MORE_TEAMS				(B_OS_ERROR_BASE + 0x104)
64 
65 #define B_BAD_PORT_ID				(B_OS_ERROR_BASE + 0x200)
66 #define B_NO_MORE_PORTS				(B_OS_ERROR_BASE + 0x201)
67 
68 #define B_BAD_IMAGE_ID				(B_OS_ERROR_BASE + 0x300)
69 #define B_BAD_ADDRESS				(B_OS_ERROR_BASE + 0x301)
70 #define B_NOT_AN_EXECUTABLE			(B_OS_ERROR_BASE + 0x302)
71 #define B_MISSING_LIBRARY			(B_OS_ERROR_BASE + 0x303)
72 #define B_MISSING_SYMBOL			(B_OS_ERROR_BASE + 0x304)
73 
74 #define B_DEBUGGER_ALREADY_INSTALLED	(B_OS_ERROR_BASE + 0x400)
75 
76 /* Application Kit Errors */
77 #define B_BAD_REPLY							(B_APP_ERROR_BASE + 0)
78 #define B_DUPLICATE_REPLY					(B_APP_ERROR_BASE + 1)
79 #define B_MESSAGE_TO_SELF					(B_APP_ERROR_BASE + 2)
80 #define B_BAD_HANDLER						(B_APP_ERROR_BASE + 3)
81 #define B_ALREADY_RUNNING					(B_APP_ERROR_BASE + 4)
82 #define B_LAUNCH_FAILED						(B_APP_ERROR_BASE + 5)
83 #define B_AMBIGUOUS_APP_LAUNCH				(B_APP_ERROR_BASE + 6)
84 #define B_UNKNOWN_MIME_TYPE					(B_APP_ERROR_BASE + 7)
85 #define B_BAD_SCRIPT_SYNTAX					(B_APP_ERROR_BASE + 8)
86 #define B_LAUNCH_FAILED_NO_RESOLVE_LINK		(B_APP_ERROR_BASE + 9)
87 #define B_LAUNCH_FAILED_EXECUTABLE			(B_APP_ERROR_BASE + 10)
88 #define B_LAUNCH_FAILED_APP_NOT_FOUND		(B_APP_ERROR_BASE + 11)
89 #define B_LAUNCH_FAILED_APP_IN_TRASH		(B_APP_ERROR_BASE + 12)
90 #define B_LAUNCH_FAILED_NO_PREFERRED_APP	(B_APP_ERROR_BASE + 13)
91 #define B_LAUNCH_FAILED_FILES_APP_NOT_FOUND	(B_APP_ERROR_BASE + 14)
92 #define B_BAD_MIME_SNIFFER_RULE				(B_APP_ERROR_BASE + 15)
93 #define B_NOT_A_MESSAGE						(B_APP_ERROR_BASE + 16)
94 #define B_SHUTDOWN_CANCELLED				(B_APP_ERROR_BASE + 17)
95 #define B_SHUTTING_DOWN						(B_APP_ERROR_BASE + 18)
96 
97 /* Storage Kit/File System Errors */
98 #define B_FILE_ERROR						(B_STORAGE_ERROR_BASE + 0)
99 #define B_FILE_NOT_FOUND					(B_STORAGE_ERROR_BASE + 1)
100 			/* deprecated: use B_ENTRY_NOT_FOUND instead */
101 #define B_FILE_EXISTS						(B_STORAGE_ERROR_BASE + 2)
102 #define B_ENTRY_NOT_FOUND					(B_STORAGE_ERROR_BASE + 3)
103 #define B_NAME_TOO_LONG						(B_STORAGE_ERROR_BASE + 4)
104 #define B_NOT_A_DIRECTORY					(B_STORAGE_ERROR_BASE + 5)
105 #define B_DIRECTORY_NOT_EMPTY				(B_STORAGE_ERROR_BASE + 6)
106 #define B_DEVICE_FULL						(B_STORAGE_ERROR_BASE + 7)
107 #define B_READ_ONLY_DEVICE					(B_STORAGE_ERROR_BASE + 8)
108 #define B_IS_A_DIRECTORY					(B_STORAGE_ERROR_BASE + 9)
109 #define B_NO_MORE_FDS						(B_STORAGE_ERROR_BASE + 10)
110 #define B_CROSS_DEVICE_LINK					(B_STORAGE_ERROR_BASE + 11)
111 #define B_LINK_LIMIT						(B_STORAGE_ERROR_BASE + 12)
112 #define B_BUSTED_PIPE						(B_STORAGE_ERROR_BASE + 13)
113 #define B_UNSUPPORTED						(B_STORAGE_ERROR_BASE + 14)
114 #define B_PARTITION_TOO_SMALL				(B_STORAGE_ERROR_BASE + 15)
115 
116 /* POSIX Errors */
117 #define E2BIG			(B_POSIX_ERROR_BASE + 1)
118 #define ECHILD			(B_POSIX_ERROR_BASE + 2)
119 #define EDEADLK			(B_POSIX_ERROR_BASE + 3)
120 #define EFBIG			(B_POSIX_ERROR_BASE + 4)
121 #define EMLINK			(B_POSIX_ERROR_BASE + 5)
122 #define ENFILE			(B_POSIX_ERROR_BASE + 6)
123 #define ENODEV			(B_POSIX_ERROR_BASE + 7)
124 #define ENOLCK			(B_POSIX_ERROR_BASE + 8)
125 #define ENOSYS			(B_POSIX_ERROR_BASE + 9)
126 #define ENOTTY			(B_POSIX_ERROR_BASE + 10)
127 #define ENXIO			(B_POSIX_ERROR_BASE + 11)
128 #define ESPIPE			(B_POSIX_ERROR_BASE + 12)
129 #define ESRCH			(B_POSIX_ERROR_BASE + 13)
130 #define EFPOS			(B_POSIX_ERROR_BASE + 14)
131 #define ESIGPARM		(B_POSIX_ERROR_BASE + 15)
132 #define EDOM			(B_POSIX_ERROR_BASE + 16)
133 #define ERANGE			(B_POSIX_ERROR_BASE + 17)
134 #define EPROTOTYPE		(B_POSIX_ERROR_BASE + 18)
135 #define EPROTONOSUPPORT	(B_POSIX_ERROR_BASE + 19)
136 #define EPFNOSUPPORT	(B_POSIX_ERROR_BASE + 20)
137 #define EAFNOSUPPORT	(B_POSIX_ERROR_BASE + 21)
138 #define EADDRINUSE		(B_POSIX_ERROR_BASE + 22)
139 #define EADDRNOTAVAIL	(B_POSIX_ERROR_BASE + 23)
140 #define ENETDOWN		(B_POSIX_ERROR_BASE + 24)
141 #define ENETUNREACH		(B_POSIX_ERROR_BASE + 25)
142 #define ENETRESET		(B_POSIX_ERROR_BASE + 26)
143 #define ECONNABORTED	(B_POSIX_ERROR_BASE + 27)
144 #define ECONNRESET		(B_POSIX_ERROR_BASE + 28)
145 #define EISCONN			(B_POSIX_ERROR_BASE + 29)
146 #define ENOTCONN		(B_POSIX_ERROR_BASE + 30)
147 #define ESHUTDOWN		(B_POSIX_ERROR_BASE + 31)
148 #define ECONNREFUSED	(B_POSIX_ERROR_BASE + 32)
149 #define EHOSTUNREACH	(B_POSIX_ERROR_BASE + 33)
150 #define ENOPROTOOPT		(B_POSIX_ERROR_BASE + 34)
151 #define ENOBUFS			(B_POSIX_ERROR_BASE + 35)
152 #define EINPROGRESS		(B_POSIX_ERROR_BASE + 36)
153 #define EALREADY		(B_POSIX_ERROR_BASE + 37)
154 #define EILSEQ          (B_POSIX_ERROR_BASE + 38)
155 #define ENOMSG          (B_POSIX_ERROR_BASE + 39)
156 #define ESTALE          (B_POSIX_ERROR_BASE + 40)
157 #define EOVERFLOW       (B_POSIX_ERROR_BASE + 41)
158 #define EMSGSIZE        (B_POSIX_ERROR_BASE + 42)
159 #define EOPNOTSUPP      (B_POSIX_ERROR_BASE + 43)
160 #define ENOTSOCK		(B_POSIX_ERROR_BASE + 44)
161 #define EHOSTDOWN		(B_POSIX_ERROR_BASE + 45)
162 #define	EBADMSG			(B_POSIX_ERROR_BASE + 46)
163 #define ECANCELED		(B_POSIX_ERROR_BASE + 47)
164 #define EDESTADDRREQ	(B_POSIX_ERROR_BASE + 48)
165 #define EDQUOT			(B_POSIX_ERROR_BASE + 49)
166 #define EIDRM			(B_POSIX_ERROR_BASE + 50)
167 #define EMULTIHOP		(B_POSIX_ERROR_BASE + 51)
168 #define ENODATA			(B_POSIX_ERROR_BASE + 52)
169 #define ENOLINK			(B_POSIX_ERROR_BASE + 53)
170 #define ENOSR			(B_POSIX_ERROR_BASE + 54)
171 #define ENOSTR			(B_POSIX_ERROR_BASE + 55)
172 #define ENOTSUP			(B_POSIX_ERROR_BASE + 56)
173 #define EPROTO			(B_POSIX_ERROR_BASE + 57)
174 #define ETIME			(B_POSIX_ERROR_BASE + 58)
175 #define ETXTBSY			(B_POSIX_ERROR_BASE + 59)
176 
177 /* POSIX errors that can be mapped to BeOS error codes */
178 #define ENOMEM			B_NO_MEMORY
179 #define EACCES			B_PERMISSION_DENIED
180 #define EINTR			B_INTERRUPTED
181 #define EIO				B_IO_ERROR
182 #define EBUSY			B_BUSY
183 #define EFAULT			B_BAD_ADDRESS
184 #define ETIMEDOUT		B_TIMED_OUT
185 #define EAGAIN 			B_WOULD_BLOCK	/* SysV compatibility */
186 #define EWOULDBLOCK 	B_WOULD_BLOCK	/* BSD compatibility */
187 #define EBADF			B_FILE_ERROR
188 #define EEXIST			B_FILE_EXISTS
189 #define EINVAL			B_BAD_VALUE
190 #define ENAMETOOLONG	B_NAME_TOO_LONG
191 #define ENOENT			B_ENTRY_NOT_FOUND
192 #define EPERM			B_NOT_ALLOWED
193 #define ENOTDIR			B_NOT_A_DIRECTORY
194 #define EISDIR			B_IS_A_DIRECTORY
195 #define ENOTEMPTY		B_DIRECTORY_NOT_EMPTY
196 #define ENOSPC			B_DEVICE_FULL
197 #define EROFS			B_READ_ONLY_DEVICE
198 #define EMFILE			B_NO_MORE_FDS
199 #define EXDEV			B_CROSS_DEVICE_LINK
200 #define ELOOP			B_LINK_LIMIT
201 #define ENOEXEC			B_NOT_AN_EXECUTABLE
202 #define EPIPE			B_BUSTED_PIPE
203 
204 /* new error codes that can be mapped to POSIX errors */
205 #define	B_BUFFER_OVERFLOW	EOVERFLOW
206 #define B_TOO_MANY_ARGS		E2BIG
207 #define	B_FILE_TOO_LARGE	EFBIG
208 #define B_RESULT_NOT_REPRESENTABLE ERANGE
209 #define	B_DEVICE_NOT_FOUND	ENODEV
210 #define B_NOT_SUPPORTED		EOPNOTSUPP
211 
212 /* Media Kit Errors */
213 #define B_STREAM_NOT_FOUND				(B_MEDIA_ERROR_BASE + 0)
214 #define B_SERVER_NOT_FOUND				(B_MEDIA_ERROR_BASE + 1)
215 #define B_RESOURCE_NOT_FOUND			(B_MEDIA_ERROR_BASE + 2)
216 #define B_RESOURCE_UNAVAILABLE			(B_MEDIA_ERROR_BASE + 3)
217 #define B_BAD_SUBSCRIBER				(B_MEDIA_ERROR_BASE + 4)
218 #define B_SUBSCRIBER_NOT_ENTERED		(B_MEDIA_ERROR_BASE + 5)
219 #define B_BUFFER_NOT_AVAILABLE			(B_MEDIA_ERROR_BASE + 6)
220 #define B_LAST_BUFFER_ERROR				(B_MEDIA_ERROR_BASE + 7)
221 
222 /* Mail Kit Errors */
223 #define B_MAIL_NO_DAEMON				(B_MAIL_ERROR_BASE + 0)
224 #define B_MAIL_UNKNOWN_USER				(B_MAIL_ERROR_BASE + 1)
225 #define B_MAIL_WRONG_PASSWORD			(B_MAIL_ERROR_BASE + 2)
226 #define B_MAIL_UNKNOWN_HOST				(B_MAIL_ERROR_BASE + 3)
227 #define B_MAIL_ACCESS_ERROR				(B_MAIL_ERROR_BASE + 4)
228 #define B_MAIL_UNKNOWN_FIELD			(B_MAIL_ERROR_BASE + 5)
229 #define B_MAIL_NO_RECIPIENT				(B_MAIL_ERROR_BASE + 6)
230 #define B_MAIL_INVALID_MAIL				(B_MAIL_ERROR_BASE + 7)
231 
232 /* Printing Errors */
233 #define B_NO_PRINT_SERVER				(B_PRINT_ERROR_BASE + 0)
234 
235 /* Device Kit Errors */
236 #define B_DEV_INVALID_IOCTL				(B_DEVICE_ERROR_BASE + 0)
237 #define B_DEV_NO_MEMORY					(B_DEVICE_ERROR_BASE + 1)
238 #define B_DEV_BAD_DRIVE_NUM				(B_DEVICE_ERROR_BASE + 2)
239 #define B_DEV_NO_MEDIA					(B_DEVICE_ERROR_BASE + 3)
240 #define B_DEV_UNREADABLE				(B_DEVICE_ERROR_BASE + 4)
241 #define B_DEV_FORMAT_ERROR				(B_DEVICE_ERROR_BASE + 5)
242 #define B_DEV_TIMEOUT					(B_DEVICE_ERROR_BASE + 6)
243 #define B_DEV_RECALIBRATE_ERROR			(B_DEVICE_ERROR_BASE + 7)
244 #define B_DEV_SEEK_ERROR				(B_DEVICE_ERROR_BASE + 8)
245 #define B_DEV_ID_ERROR					(B_DEVICE_ERROR_BASE + 9)
246 #define B_DEV_READ_ERROR				(B_DEVICE_ERROR_BASE + 10)
247 #define B_DEV_WRITE_ERROR				(B_DEVICE_ERROR_BASE + 11)
248 #define B_DEV_NOT_READY					(B_DEVICE_ERROR_BASE + 12)
249 #define B_DEV_MEDIA_CHANGED				(B_DEVICE_ERROR_BASE + 13)
250 #define B_DEV_MEDIA_CHANGE_REQUESTED	(B_DEVICE_ERROR_BASE + 14)
251 #define B_DEV_RESOURCE_CONFLICT			(B_DEVICE_ERROR_BASE + 15)
252 #define B_DEV_CONFIGURATION_ERROR		(B_DEVICE_ERROR_BASE + 16)
253 #define B_DEV_DISABLED_BY_USER			(B_DEVICE_ERROR_BASE + 17)
254 #define B_DEV_DOOR_OPEN					(B_DEVICE_ERROR_BASE + 18)
255 
256 #define B_DEV_INVALID_PIPE				(B_DEVICE_ERROR_BASE + 19)
257 #define B_DEV_CRC_ERROR					(B_DEVICE_ERROR_BASE + 20)
258 #define B_DEV_STALLED					(B_DEVICE_ERROR_BASE + 21)
259 #define B_DEV_BAD_PID					(B_DEVICE_ERROR_BASE + 22)
260 #define B_DEV_UNEXPECTED_PID			(B_DEVICE_ERROR_BASE + 23)
261 #define B_DEV_DATA_OVERRUN				(B_DEVICE_ERROR_BASE + 24)
262 #define B_DEV_DATA_UNDERRUN				(B_DEVICE_ERROR_BASE + 25)
263 #define B_DEV_FIFO_OVERRUN				(B_DEVICE_ERROR_BASE + 26)
264 #define B_DEV_FIFO_UNDERRUN				(B_DEVICE_ERROR_BASE + 27)
265 #define B_DEV_PENDING					(B_DEVICE_ERROR_BASE + 28)
266 #define B_DEV_MULTIPLE_ERRORS			(B_DEVICE_ERROR_BASE + 29)
267 #define B_DEV_TOO_LATE					(B_DEVICE_ERROR_BASE + 30)
268 
269 #endif	/* _ERRORS_H */
270