nsError.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsError_h__
00039 #define nsError_h__
00040 
00041 #ifndef nscore_h___
00042 #include "nscore.h"  /* needed for nsresult */
00043 #endif
00044 
00045 /*
00046  * To add error code to your module, you need to do the following:
00047  *
00048  * 1) Add a module offset code.  Add yours to the bottom of the list 
00049  *    right below this comment, adding 1.
00050  *
00051  * 2) In your module, define a header file which uses one of the
00052  *    NE_ERROR_GENERATExxxxxx macros.  Some examples below:
00053  *
00054  *    #define NS_ERROR_MYMODULE_MYERROR1 NS_ERROR_GENERATE(NS_ERROR_SEVERITY_ERROR,NS_ERROR_MODULE_MYMODULE,1)
00055  *    #define NS_ERROR_MYMODULE_MYERROR2 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_MYMODULE,2)
00056  *    #define NS_ERROR_MYMODULE_MYERROR3 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_MYMODULE,3)
00057  *
00058  */
00059 
00060 
00061 /**
00062  * @name Standard Module Offset Code. Each Module should identify a unique number
00063  *       and then all errors associated with that module become offsets from the
00064  *       base associated with that module id. There are 16 bits of code bits for
00065  *       each module.
00066  */
00067 
00068 #define NS_ERROR_MODULE_XPCOM      1
00069 #define NS_ERROR_MODULE_BASE       2
00070 #define NS_ERROR_MODULE_GFX        3
00071 #define NS_ERROR_MODULE_WIDGET     4
00072 #define NS_ERROR_MODULE_CALENDAR   5
00073 #define NS_ERROR_MODULE_NETWORK    6
00074 #define NS_ERROR_MODULE_PLUGINS    7
00075 #define NS_ERROR_MODULE_LAYOUT     8
00076 #define NS_ERROR_MODULE_HTMLPARSER 9
00077 #define NS_ERROR_MODULE_RDF        10
00078 #define NS_ERROR_MODULE_UCONV      11
00079 #define NS_ERROR_MODULE_REG        12
00080 #define NS_ERROR_MODULE_FILES      13
00081 #define NS_ERROR_MODULE_DOM        14
00082 #define NS_ERROR_MODULE_IMGLIB     15
00083 #define NS_ERROR_MODULE_MAILNEWS   16
00084 #define NS_ERROR_MODULE_EDITOR     17
00085 #define NS_ERROR_MODULE_XPCONNECT  18
00086 #define NS_ERROR_MODULE_PROFILE    19
00087 #define NS_ERROR_MODULE_LDAP       20
00088 #define NS_ERROR_MODULE_SECURITY   21
00089 #define NS_ERROR_MODULE_DOM_XPATH  22
00090 #define NS_ERROR_MODULE_DOM_RANGE  23
00091 #define NS_ERROR_MODULE_URILOADER  24
00092 #define NS_ERROR_MODULE_CONTENT    25
00093 #define NS_ERROR_MODULE_PYXPCOM    26
00094 #define NS_ERROR_MODULE_XSLT       27
00095 #define NS_ERROR_MODULE_IPC        28
00096 #define NS_ERROR_MODULE_SVG        29
00097 #define NS_ERROR_MODULE_STORAGE    30
00098 #define NS_ERROR_MODULE_SCHEMA     31
00099 
00100 /* NS_ERROR_MODULE_GENERAL should be used by modules that do not
00101  * care if return code values overlap. Callers of methods that
00102  * return such codes should be aware that they are not
00103  * globally unique. Implementors should be careful about blindly
00104  * returning codes from other modules that might also use
00105  * the generic base.
00106  */
00107 #define NS_ERROR_MODULE_GENERAL    51  
00108 
00109 /**
00110  * @name Standard Error Handling Macros
00111  */
00112 
00113 #define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
00114 #define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
00115 
00116 /**
00117  * @name Severity Code.  This flag identifies the level of warning
00118  */
00119 
00120 #define NS_ERROR_SEVERITY_SUCCESS       0
00121 #define NS_ERROR_SEVERITY_ERROR         1
00122 
00123 /**
00124  * @name Mozilla Code.  This flag separates consumers of mozilla code
00125  *       from the native platform
00126  */
00127 
00128 #define NS_ERROR_MODULE_BASE_OFFSET 0x45
00129 
00130 /**
00131  * @name Standard Error Generating Macros
00132  */
00133 
00134 #define NS_ERROR_GENERATE(sev,module,code) \
00135     ((nsresult) (((PRUint32)(sev)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
00136 
00137 #define NS_ERROR_GENERATE_SUCCESS(module,code) \
00138     ((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_SUCCESS)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
00139 
00140 #define NS_ERROR_GENERATE_FAILURE(module,code) \
00141     ((nsresult) (((PRUint32)(NS_ERROR_SEVERITY_ERROR)<<31) | ((PRUint32)(module+NS_ERROR_MODULE_BASE_OFFSET)<<16) | ((PRUint32)(code))) )
00142 
00143 /**
00144  * @name Standard Macros for retrieving error bits
00145  */
00146 
00147 #define NS_ERROR_GET_CODE(err)     ((err) & 0xffff)
00148 #define NS_ERROR_GET_MODULE(err)   (((((err) >> 16) - NS_ERROR_MODULE_BASE_OFFSET) & 0x1fff))
00149 #define NS_ERROR_GET_SEVERITY(err) (((err) >> 31) & 0x1)
00150 
00151 /**
00152  * @name Standard return values
00153  */
00154 
00155 /*@{*/
00156 
00157 /* Standard "it worked" return value */
00158 #define NS_OK                              0
00159 
00160 #define NS_ERROR_BASE                      ((nsresult) 0xC1F30000)
00161 
00162 /* Returned when an instance is not initialized */
00163 #define NS_ERROR_NOT_INITIALIZED           (NS_ERROR_BASE + 1)
00164 
00165 /* Returned when an instance is already initialized */
00166 #define NS_ERROR_ALREADY_INITIALIZED       (NS_ERROR_BASE + 2)
00167 
00168 /* Returned by a not implemented function */
00169 #define NS_ERROR_NOT_IMPLEMENTED           ((nsresult) 0x80004001L)
00170 
00171 /* Returned when a given interface is not supported. */
00172 #define NS_NOINTERFACE                     ((nsresult) 0x80004002L)
00173 #define NS_ERROR_NO_INTERFACE              NS_NOINTERFACE
00174 
00175 #define NS_ERROR_INVALID_POINTER           ((nsresult) 0x80004003L)
00176 #define NS_ERROR_NULL_POINTER              NS_ERROR_INVALID_POINTER
00177 
00178 /* Returned when a function aborts */
00179 #define NS_ERROR_ABORT                     ((nsresult) 0x80004004L)
00180 
00181 /* Returned when a function fails */
00182 #define NS_ERROR_FAILURE                   ((nsresult) 0x80004005L)
00183 
00184 /* Returned when an unexpected error occurs */
00185 #define NS_ERROR_UNEXPECTED                ((nsresult) 0x8000ffffL)
00186 
00187 /* Returned when a memory allocation fails */
00188 #define NS_ERROR_OUT_OF_MEMORY             ((nsresult) 0x8007000eL)
00189 
00190 /* Returned when an illegal value is passed */
00191 #define NS_ERROR_ILLEGAL_VALUE             ((nsresult) 0x80070057L)
00192 #define NS_ERROR_INVALID_ARG               NS_ERROR_ILLEGAL_VALUE
00193 
00194 /* Returned when a class doesn't allow aggregation */
00195 #define NS_ERROR_NO_AGGREGATION            ((nsresult) 0x80040110L)
00196 
00197 /* Returned when an operation can't complete due to an unavailable resource */
00198 #define NS_ERROR_NOT_AVAILABLE             ((nsresult) 0x80040111L)
00199 
00200 /* Returned when a class is not registered */
00201 #define NS_ERROR_FACTORY_NOT_REGISTERED    ((nsresult) 0x80040154L)
00202 
00203 /* Returned when a class cannot be registered, but may be tried again later */
00204 #define NS_ERROR_FACTORY_REGISTER_AGAIN    ((nsresult) 0x80040155L)
00205 
00206 /* Returned when a dynamically loaded factory couldn't be found */
00207 #define NS_ERROR_FACTORY_NOT_LOADED        ((nsresult) 0x800401f8L)
00208 
00209 /* Returned when a factory doesn't support signatures */
00210 #define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
00211                                            (NS_ERROR_BASE + 0x101)
00212 
00213 /* Returned when a factory already is registered */
00214 #define NS_ERROR_FACTORY_EXISTS            (NS_ERROR_BASE + 0x100)
00215 
00216 
00217 /* For COM compatibility reasons, we want to use exact error code numbers
00218    for NS_ERROR_PROXY_INVALID_IN_PARAMETER and NS_ERROR_PROXY_INVALID_OUT_PARAMETER.
00219    The first matches:
00220 
00221      #define RPC_E_INVALID_PARAMETER          _HRESULT_TYPEDEF_(0x80010010L)
00222    
00223    Errors returning this mean that the xpcom proxy code could not create a proxy for
00224    one of the in paramaters.
00225 
00226    Because of this, we are ignoring the convention if using a base and offset for
00227    error numbers.
00228 
00229 */
00230 
00231 /* Returned when a proxy could not be create a proxy for one of the IN parameters
00232    This is returned only when the "real" meathod has NOT been invoked. 
00233 */
00234 
00235 #define NS_ERROR_PROXY_INVALID_IN_PARAMETER        ((nsresult) 0x80010010L)
00236 
00237 /* Returned when a proxy could not be create a proxy for one of the OUT parameters
00238    This is returned only when the "real" meathod has ALREADY been invoked. 
00239 */
00240 
00241 #define NS_ERROR_PROXY_INVALID_OUT_PARAMETER        ((nsresult) 0x80010011L)
00242 
00243 
00244 /*@}*/
00245 
00246  /* I/O Errors */
00247 
00248  /*  Stream closed */
00249 #define NS_BASE_STREAM_CLOSED         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 2)
00250  /*  Error from the operating system */
00251 #define NS_BASE_STREAM_OSERROR        NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 3)
00252  /*  Illegal arguments */
00253 #define NS_BASE_STREAM_ILLEGAL_ARGS   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 4)
00254  /*  For unichar streams */
00255 #define NS_BASE_STREAM_NO_CONVERTER   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 5)
00256  /*  For unichar streams */
00257 #define NS_BASE_STREAM_BAD_CONVERSION NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 6)
00258 
00259 #define NS_BASE_STREAM_WOULD_BLOCK    NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_BASE, 7)
00260 
00261 
00262 #define NS_ERROR_FILE_UNRECOGNIZED_PATH         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 1)
00263 #define NS_ERROR_FILE_UNRESOLVABLE_SYMLINK      NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 2)
00264 #define NS_ERROR_FILE_EXECUTION_FAILED          NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 3)
00265 #define NS_ERROR_FILE_UNKNOWN_TYPE              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 4)
00266 #define NS_ERROR_FILE_DESTINATION_NOT_DIR       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 5)
00267 #define NS_ERROR_FILE_TARGET_DOES_NOT_EXIST     NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 6)
00268 #define NS_ERROR_FILE_COPY_OR_MOVE_FAILED       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 7)
00269 #define NS_ERROR_FILE_ALREADY_EXISTS            NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 8)
00270 #define NS_ERROR_FILE_INVALID_PATH              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 9)
00271 #define NS_ERROR_FILE_DISK_FULL                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 10)
00272 #define NS_ERROR_FILE_CORRUPTED                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 11)
00273 #define NS_ERROR_FILE_NOT_DIRECTORY             NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 12)
00274 #define NS_ERROR_FILE_IS_DIRECTORY              NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 13)
00275 #define NS_ERROR_FILE_IS_LOCKED                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 14)
00276 #define NS_ERROR_FILE_TOO_BIG                   NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 15)
00277 #define NS_ERROR_FILE_NO_DEVICE_SPACE           NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 16)
00278 #define NS_ERROR_FILE_NAME_TOO_LONG             NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 17)
00279 #define NS_ERROR_FILE_NOT_FOUND                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 18)
00280 #define NS_ERROR_FILE_READ_ONLY                 NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 19)
00281 #define NS_ERROR_FILE_DIR_NOT_EMPTY             NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 20)
00282 #define NS_ERROR_FILE_ACCESS_DENIED             NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES, 21)
00283 
00284 #define NS_SUCCESS_FILE_DIRECTORY_EMPTY         NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_FILES, 1)
00285 
00286  /* Result codes used by nsIDirectoryServiceProvider2 */
00287 
00288 #define NS_SUCCESS_AGGREGATE_RESULT             NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_FILES, 2)
00289 
00290  /* Result codes used by nsIVariant */
00291 
00292 #define NS_ERROR_CANNOT_CONVERT_DATA            NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM,  1)
00293 #define NS_ERROR_OBJECT_IS_IMMUTABLE            NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM,  2)
00294 #define NS_ERROR_LOSS_OF_SIGNIFICANT_DATA       NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM,  3)
00295 
00296 #define NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA   NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_XPCOM,  1)
00297 
00298 
00299  /*
00300   * This will return the nsresult corresponding to the most recent NSPR failure
00301   * returned by PR_GetError.
00302   *
00303   ***********************************************************************
00304   *      Do not depend on this function. It will be going away!
00305   ***********************************************************************
00306   */
00307 extern NS_COM nsresult
00308 NS_ErrorAccordingToNSPR();
00309 
00310 
00311 #ifdef _MSC_VER
00312 #pragma warning(disable: 4251) /* 'nsCOMPtr<class nsIInputStream>' needs to have dll-interface to be used by clients of class 'nsInputStream' */
00313 #pragma warning(disable: 4275) /* non dll-interface class 'nsISupports' used as base for dll-interface class 'nsIRDFNode' */
00314 #endif
00315 
00316 #endif
00317 
Generated by  doxygen 1.6.2-20100208