1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
---|
2 | /* ***** BEGIN LICENSE BLOCK *****
|
---|
3 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
---|
4 | *
|
---|
5 | * The contents of this file are subject to the Mozilla Public License Version
|
---|
6 | * 1.1 (the "License"); you may not use this file except in compliance with
|
---|
7 | * the License. You may obtain a copy of the License at
|
---|
8 | * http://www.mozilla.org/MPL/
|
---|
9 | *
|
---|
10 | * Software distributed under the License is distributed on an "AS IS" basis,
|
---|
11 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
---|
12 | * for the specific language governing rights and limitations under the
|
---|
13 | * License.
|
---|
14 | *
|
---|
15 | * The Original Code is mozilla.org code.
|
---|
16 | *
|
---|
17 | * The Initial Developer of the Original Code is
|
---|
18 | * Netscape Communications Corporation.
|
---|
19 | * Portions created by the Initial Developer are Copyright (C) 1998
|
---|
20 | * the Initial Developer. All Rights Reserved.
|
---|
21 | *
|
---|
22 | * Contributor(s):
|
---|
23 | *
|
---|
24 | * Alternatively, the contents of this file may be used under the terms of
|
---|
25 | * either of the GNU General Public License Version 2 or later (the "GPL"),
|
---|
26 | * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
---|
27 | * in which case the provisions of the GPL or the LGPL are applicable instead
|
---|
28 | * of those above. If you wish to allow use of your version of this file only
|
---|
29 | * under the terms of either the GPL or the LGPL, and not to allow others to
|
---|
30 | * use your version of this file under the terms of the MPL, indicate your
|
---|
31 | * decision by deleting the provisions above and replace them with the notice
|
---|
32 | * and other provisions required by the GPL or the LGPL. If you do not delete
|
---|
33 | * the provisions above, a recipient may use your version of this file under
|
---|
34 | * the terms of any one of the MPL, the GPL or the LGPL.
|
---|
35 | *
|
---|
36 | * ***** END LICENSE BLOCK ***** */
|
---|
37 |
|
---|
38 | #ifndef nsError_h__
|
---|
39 | #define nsError_h__
|
---|
40 |
|
---|
41 | #ifndef nscore_h___
|
---|
42 | #include "nscore.h" /* needed for nsresult */
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | /*
|
---|
46 | * To add error code to your module, you need to do the following:
|
---|
47 | *
|
---|
48 | * 1) Add a module offset code. Add yours to the bottom of the list
|
---|
49 | * right below this comment, adding 1.
|
---|
50 | *
|
---|
51 | * 2) In your module, define a header file which uses one of the
|
---|
52 | * NE_ERROR_GENERATExxxxxx macros. Some examples below:
|
---|
53 | *
|
---|
54 | * #define NS_ERROR_MYMODULE_MYERROR1 NS_ERROR_GENERATE(NS_ERROR_SEVERITY_ERROR,NS_ERROR_MODULE_MYMODULE,1)
|
---|
55 | * #define NS_ERROR_MYMODULE_MYERROR2 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_MYMODULE,2)
|
---|
56 | * #define NS_ERROR_MYMODULE_MYERROR3 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MYMODULE,3)
|
---|
57 | *
|
---|
58 | */
|
---|
59 |
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * @name Standard Module Offset Code. Each Module should identify a unique number
|
---|
63 | * and then all errors associated with that module become offsets from the
|
---|
64 | * base associated with that module id. There are 16 bits of code bits for
|
---|
65 | * each module.
|
---|
66 | */
|
---|
67 |
|
---|
68 | #define NS_ERROR_MODULE_XPCOM 1
|
---|
69 | #define NS_ERROR_MODULE_BASE 2
|
---|
70 | #define NS_ERROR_MODULE_GFX 3
|
---|
71 | #define NS_ERROR_MODULE_WIDGET 4
|
---|
72 | #define NS_ERROR_MODULE_CALENDAR 5
|
---|
73 | #define NS_ERROR_MODULE_NETWORK 6
|
---|
74 | #define NS_ERROR_MODULE_PLUGINS 7
|
---|
75 | #define NS_ERROR_MODULE_LAYOUT 8
|
---|
76 | #define NS_ERROR_MODULE_HTMLPARSER 9
|
---|
77 | #define NS_ERROR_MODULE_RDF 10
|
---|
78 | #define NS_ERROR_MODULE_UCONV 11
|
---|
79 | #define NS_ERROR_MODULE_REG 12
|
---|
80 | #define NS_ERROR_MODULE_FILES 13
|
---|
81 | #define NS_ERROR_MODULE_DOM 14
|
---|
82 | #define NS_ERROR_MODULE_IMGLIB 15
|
---|
83 | #define NS_ERROR_MODULE_MAILNEWS 16
|
---|
84 | #define NS_ERROR_MODULE_EDITOR 17
|
---|
85 | #define NS_ERROR_MODULE_XPCONNECT 18
|
---|
86 | #define NS_ERROR_MODULE_PROFILE 19
|
---|
87 | #define NS_ERROR_MODULE_LDAP 20
|
---|
88 | #define NS_ERROR_MODULE_SECURITY 21
|
---|
89 | #define NS_ERROR_MODULE_DOM_XPATH 22
|
---|
90 | #define NS_ERROR_MODULE_DOM_RANGE 23
|
---|
91 | #define NS_ERROR_MODULE_URILOADER 24
|
---|
92 | #define NS_ERROR_MODULE_CONTENT 25
|
---|
93 | #define NS_ERROR_MODULE_PYXPCOM 26
|
---|
94 | #define NS_ERROR_MODULE_XSLT 27
|
---|
95 | #define NS_ERROR_MODULE_IPC 28
|
---|
96 | #define NS_ERROR_MODULE_SVG 29
|
---|
97 |
|
---|
98 | /* NS_ERROR_MODULE_GENERAL should be used by modules that do not
|
---|
99 | * care if return code values overlap. Callers of methods that
|
---|
100 | * return such codes should be aware that they are not
|
---|
101 | * globally unique. Implementors should be careful about blindly
|
---|
102 | * returning codes from other modules that might also use
|
---|
103 | * the generic base.
|
---|
104 | */
|
---|
105 | #define NS_ERROR_MODULE_GENERAL 51
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * @name Standard Error Handling Macros
|
---|
109 | */
|
---|
110 |
|
---|
111 | #define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
|
---|
112 | #define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
|
---|
113 |
|
---|
114 | /**
|
---|
115 | * @name Severity Code. This flag identifies the level of warning
|
---|
116 | */
|
---|
117 |
|
---|
118 | #define NS_ERROR_SEVERITY_SUCCESS 0
|
---|
119 | #define NS_ERROR_SEVERITY_ERROR 1
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * @name Mozilla Code. This flag separates consumers of mozilla code
|
---|
123 | * from the native platform
|
---|
124 | */
|
---|
125 |
|
---|
126 | #define NS_ERROR_MODULE_BASE_OFFSET 0x45
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * @name Standard Error Generating Macros
|
---|
130 | */
|
---|
131 |
|
---|
132 | #define NS_ERROR_GENERATE(sev,module,code) \
|
---|
133 | ((nsresult) (((PRUint32)(sev)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
|
---|
134 |
|
---|
135 | #define NS_ERROR_GENERATE_SUCCESS(module,code) \
|
---|
136 | ((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_SUCCESS)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
|
---|
137 |
|
---|
138 | #define NS_ERROR_GENERATE_FAILURE(module,code) \
|
---|
139 | ((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_ERROR)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
|
---|
140 |
|
---|
141 | /**
|
---|
142 | * @name Standard Macros for retrieving error bits
|
---|
143 | */
|
---|
144 |
|
---|
145 | #define NS_ERROR_GET_CODE(err) ((err) & 0xffff)
|
---|
146 | #define NS_ERROR_GET_MODULE(err) (((((err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff))
|
---|
147 | #define NS_ERROR_GET_SEVERITY(err) (((err) >> 31) & 0x1)
|
---|
148 |
|
---|
149 | /**
|
---|
150 | * @name Standard return values
|
---|
151 | */
|
---|
152 |
|
---|
153 | /*@{*/
|
---|
154 |
|
---|
155 | /* Standard "it worked" return value */
|
---|
156 | #define NS_OK 0
|
---|
157 |
|
---|
158 | #define NS_ERROR_BASE ((nsresult) 0xC1F30000)
|
---|
159 |
|
---|
160 | /* Returned when an instance is not initialized */
|
---|
161 | #define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
|
---|
162 |
|
---|
163 | /* Returned when an instance is already initialized */
|
---|
164 | #define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
|
---|
165 |
|
---|
166 | /* Returned by a not implemented function */
|
---|
167 | #define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
|
---|
168 |
|
---|
169 | /* Returned when a given interface is not supported. */
|
---|
170 | #define NS_NOINTERFACE ((nsresult) 0x80004002L)
|
---|
171 | #define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
|
---|
172 |
|
---|
173 | #define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
|
---|
174 | #define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
|
---|
175 |
|
---|
176 | /* Returned when a function aborts */
|
---|
177 | #define NS_ERROR_ABORT ((nsresult) 0x80004004L)
|
---|
178 |
|
---|
179 | /* Returned when a function fails */
|
---|
180 | #define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
|
---|
181 |
|
---|
182 | /* Returned when an IPC fails */
|
---|
183 | #define NS_ERROR_CALL_FAILED ((nsresult) 0x800706beL)
|
---|
184 |
|
---|
185 | /* Returned when an unexpected error occurs */
|
---|
186 | #define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
|
---|
187 |
|
---|
188 | /* Returned when a memory allocation fails */
|
---|
189 | #define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
|
---|
190 |
|
---|
191 | /* Returned when an illegal value is passed */
|
---|
192 | #define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
|
---|
193 | #define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
|
---|
194 |
|
---|
195 | /* Returned when a class doesn't allow aggregation */
|
---|
196 | #define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
|
---|
197 |
|
---|
198 | /* Returned when an operation can't complete due to an unavailable resource */
|
---|
199 | #define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
|
---|
200 |
|
---|
201 | /* Returned when a class is not registered */
|
---|
202 | #define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
|
---|
203 |
|
---|
204 | /* Returned when a class cannot be registered, but may be tried again later */
|
---|
205 | #define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
|
---|
206 |
|
---|
207 | /* Returned when a dynamically loaded factory couldn't be found */
|
---|
208 | #define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
|
---|
209 |
|
---|
210 | /* Returned when a factory doesn't support signatures */
|
---|
211 | #define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
|
---|
212 | (NS_ERROR_BASE + 0x101)
|
---|
213 |
|
---|
214 | /* Returned when a factory already is registered */
|
---|
215 | #define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
|
---|
216 |
|
---|
217 | /* Socket failures */
|
---|
218 | #define NS_ERROR_SOCKET_FAIL (NS_ERROR_BASE + 0x200)
|
---|
219 |
|
---|
220 |
|
---|
221 | /* For COM compatibility reasons, we want to use exact error code numbers
|
---|
222 | for NS_ERROR_PROXY_INVALID_IN_PARAMETER and NS_ERROR_PROXY_INVALID_OUT_PARAMETER.
|
---|
223 | The first matches:
|
---|
224 |
|
---|
225 | #define RPC_E_INVALID_PARAMETER _HRESULT_TYPEDEF_(0x80010010L)
|
---|
226 |
|
---|
227 | Errors returning this mean that the xpcom proxy code could not create a proxy for
|
---|
228 | one of the in paramaters.
|
---|
229 |
|
---|
230 | Because of this, we are ignoring the convention if using a base and offset for
|
---|
231 | error numbers.
|
---|
232 |
|
---|
233 | */
|
---|
234 |
|
---|
235 | /* Returned when a proxy could not be create a proxy for one of the IN parameters
|
---|
236 | This is returned only when the "real" meathod has NOT been invoked.
|
---|
237 | */
|
---|
238 |
|
---|
239 | #define NS_ERROR_PROXY_INVALID_IN_PARAMETER ((nsresult) 0x80010010L)
|
---|
240 |
|
---|
241 | /* Returned when a proxy could not be create a proxy for one of the OUT parameters
|
---|
242 | This is returned only when the "real" meathod has ALREADY been invoked.
|
---|
243 | */
|
---|
244 |
|
---|
245 | #define NS_ERROR_PROXY_INVALID_OUT_PARAMETER ((nsresult) 0x80010011L)
|
---|
246 |
|
---|
247 |
|
---|
248 | /*@}*/
|
---|
249 |
|
---|
250 | /* I/O Errors */
|
---|
251 |
|
---|
252 | /* Stream closed */
|
---|
253 | #define NS_BASE_STREAM_CLOSED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
|
---|
254 | /* Error from the operating system */
|
---|
255 | #define NS_BASE_STREAM_OSERROR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3)
|
---|
256 | /* Illegal arguments */
|
---|
257 | #define NS_BASE_STREAM_ILLEGAL_ARGS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4)
|
---|
258 | /* For unichar streams */
|
---|
259 | #define NS_BASE_STREAM_NO_CONVERTER NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5)
|
---|
260 | /* For unichar streams */
|
---|
261 | #define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6)
|
---|
262 |
|
---|
263 | #define NS_BASE_STREAM_WOULD_BLOCK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 7)
|
---|
264 |
|
---|
265 |
|
---|
266 | #define NS_ERROR_FILE_UNRECOGNIZED_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 1)
|
---|
267 | #define NS_ERROR_FILE_UNRESOLVABLE_SYMLINK NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 2)
|
---|
268 | #define NS_ERROR_FILE_EXECUTION_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 3)
|
---|
269 | #define NS_ERROR_FILE_UNKNOWN_TYPE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 4)
|
---|
270 | #define NS_ERROR_FILE_DESTINATION_NOT_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 5)
|
---|
271 | #define NS_ERROR_FILE_TARGET_DOES_NOT_EXIST NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 6)
|
---|
272 | #define NS_ERROR_FILE_COPY_OR_MOVE_FAILED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 7)
|
---|
273 | #define NS_ERROR_FILE_ALREADY_EXISTS NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 8)
|
---|
274 | #define NS_ERROR_FILE_INVALID_PATH NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 9)
|
---|
275 | #define NS_ERROR_FILE_DISK_FULL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 10)
|
---|
276 | #define NS_ERROR_FILE_CORRUPTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 11)
|
---|
277 | #define NS_ERROR_FILE_NOT_DIRECTORY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 12)
|
---|
278 | #define NS_ERROR_FILE_IS_DIRECTORY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 13)
|
---|
279 | #define NS_ERROR_FILE_IS_LOCKED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 14)
|
---|
280 | #define NS_ERROR_FILE_TOO_BIG NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 15)
|
---|
281 | #define NS_ERROR_FILE_NO_DEVICE_SPACE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 16)
|
---|
282 | #define NS_ERROR_FILE_NAME_TOO_LONG NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 17)
|
---|
283 | #define NS_ERROR_FILE_NOT_FOUND NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 18)
|
---|
284 | #define NS_ERROR_FILE_READ_ONLY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 19)
|
---|
285 | #define NS_ERROR_FILE_DIR_NOT_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 20)
|
---|
286 | #define NS_ERROR_FILE_ACCESS_DENIED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 21)
|
---|
287 |
|
---|
288 | #define NS_SUCCESS_FILE_DIRECTORY_EMPTY NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_FILES, 1)
|
---|
289 |
|
---|
290 | /* Result codes used by nsIVariant */
|
---|
291 |
|
---|
292 | #define NS_ERROR_CANNOT_CONVERT_DATA NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 1)
|
---|
293 | #define NS_ERROR_OBJECT_IS_IMMUTABLE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 2)
|
---|
294 | #define NS_ERROR_LOSS_OF_SIGNIFICANT_DATA NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 3)
|
---|
295 |
|
---|
296 | #define NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM, 1)
|
---|
297 |
|
---|
298 |
|
---|
299 | /*
|
---|
300 | * This will return the nsresult corresponding to the most recent NSPR failure
|
---|
301 | * returned by PR_GetError.
|
---|
302 | *
|
---|
303 | ***********************************************************************
|
---|
304 | * Do not depend on this function. It will be going away!
|
---|
305 | ***********************************************************************
|
---|
306 | */
|
---|
307 | extern NS_COM nsresult
|
---|
308 | NS_ErrorAccordingToNSPR();
|
---|
309 |
|
---|
310 |
|
---|
311 | #ifdef _MSC_VER
|
---|
312 | #pragma warning(disable: 4251) /* 'nsCOMPtr<class nsIInputStream>' needs to have dll-interface to be used by clients of class 'nsInputStream' */
|
---|
313 | #pragma warning(disable: 4275) /* non dll-interface class 'nsISupports' used as base for dll-interface class 'nsIRDFNode' */
|
---|
314 | #endif
|
---|
315 |
|
---|
316 | #endif
|
---|
317 |
|
---|