1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
42 #ifndef _CXCORE_ERROR_H_
43 #define _CXCORE_ERROR_H_
45 /************Below is declaration of error handling stuff in PLSuite manner**/
49 /* this part of CVStatus is compatible with IPLStatus
50 Some of below symbols are not [yet] used in OpenCV
52 #define CV_StsOk 0 /* everithing is ok */
53 #define CV_StsBackTrace -1 /* pseudo error for back trace */
54 #define CV_StsError -2 /* unknown /unspecified error */
55 #define CV_StsInternal -3 /* internal error (bad state) */
56 #define CV_StsNoMem -4 /* insufficient memory */
57 #define CV_StsBadArg -5 /* function arg/param is bad */
58 #define CV_StsBadFunc -6 /* unsupported function */
59 #define CV_StsNoConv -7 /* iter. didn't converge */
60 #define CV_StsAutoTrace -8 /* tracing */
62 #define CV_HeaderIsNull -9 /* image header is NULL */
63 #define CV_BadImageSize -10 /* image size is invalid */
64 #define CV_BadOffset -11 /* offset is invalid */
65 #define CV_BadDataPtr -12 /**/
66 #define CV_BadStep -13 /**/
67 #define CV_BadModelOrChSeq -14 /**/
68 #define CV_BadNumChannels -15 /**/
69 #define CV_BadNumChannel1U -16 /**/
70 #define CV_BadDepth -17 /**/
71 #define CV_BadAlphaChannel -18 /**/
72 #define CV_BadOrder -19 /**/
73 #define CV_BadOrigin -20 /**/
74 #define CV_BadAlign -21 /**/
75 #define CV_BadCallBack -22 /**/
76 #define CV_BadTileSize -23 /**/
77 #define CV_BadCOI -24 /**/
78 #define CV_BadROISize -25 /**/
80 #define CV_MaskIsTiled -26 /**/
82 #define CV_StsNullPtr -27 /* null pointer */
83 #define CV_StsVecLengthErr -28 /* incorrect vector length */
84 #define CV_StsFilterStructContentErr -29 /* incorr. filter structure content */
85 #define CV_StsKernelStructContentErr -30 /* incorr. transform kernel content */
86 #define CV_StsFilterOffsetErr -31 /* incorrect filter ofset value */
89 #define CV_StsBadSize -201 /* the input/output structure size is incorrect */
90 #define CV_StsDivByZero -202 /* division by zero */
91 #define CV_StsInplaceNotSupported -203 /* in-place operation is not supported */
92 #define CV_StsObjectNotFound -204 /* request can't be completed */
93 #define CV_StsUnmatchedFormats -205 /* formats of input/output arrays differ */
94 #define CV_StsBadFlag -206 /* flag is wrong or not supported */
95 #define CV_StsBadPoint -207 /* bad CvPoint */
96 #define CV_StsBadMask -208 /* bad format of mask (neither 8uC1 nor 8sC1)*/
97 #define CV_StsUnmatchedSizes -209 /* sizes of input/output structures do not match */
98 #define CV_StsUnsupportedFormat -210 /* the data format/type is not supported by the function*/
99 #define CV_StsOutOfRange -211 /* some of parameters are out of range */
100 #define CV_StsParseError -212 /* invalid syntax/structure of the parsed file */
101 #define CV_StsNotImplemented -213 /* the requested function/feature is not implemented */
102 #define CV_StsBadMemBlock -214 /* an allocated block has been corrupted */
103 #define CV_StsAssert -215 /* assertion failed */
105 /********************************* Error handling Macros ********************************/
107 #define OPENCV_ERROR(status,func,context) \
108 cvError((status),(func),(context),__FILE__,__LINE__)
110 #define OPENCV_ERRCHK(func,context) \
111 {if (cvGetErrStatus() >= 0) \
112 {OPENCV_ERROR(CV_StsBackTrace,(func),(context));}}
114 #define OPENCV_ASSERT(expr,func,context) \
116 {OPENCV_ERROR(CV_StsInternal,(func),(context));}}
118 #define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk))
120 #define OPENCV_CALL( Func ) \
126 /**************************** OpenCV-style error handling *******************************/
128 /* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */
129 #ifdef CV_NO_FUNC_NAMES
130 #define CV_FUNCNAME( Name )
131 #define cvFuncName ""
133 #define CV_FUNCNAME( Name ) \
134 static char cvFuncName[] = Name
139 CV_ERROR macro unconditionally raises error with passed code and message.
140 After raising error, control will be transferred to the exit label.
142 #define CV_ERROR( Code, Msg ) \
144 cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \
148 /* Simplified form of CV_ERROR */
149 #define CV_ERROR_FROM_CODE( code ) \
153 CV_CHECK macro checks error status after CV (or IPL)
154 function call. If error detected, control will be transferred to the exit
159 if( cvGetErrStatus() < 0 ) \
160 CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \
165 CV_CALL macro calls CV (or IPL) function, checks error status and
166 signals a error if the function failed. Useful in "parent node"
169 #define CV_CALL( Func ) \
176 /* Runtime assertion macro */
177 #define CV_ASSERT( Condition ) \
180 CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \
184 #define __END__ goto exit; exit: ; }
186 #define EXIT goto exit
188 #endif /* _CXCORE_ERROR_H_ */