CVB++ 15.0
exception.hpp
1#pragma once
2
3#include <exception>
4#include <new>
5#include <stdexcept>
6
7#include "_cexports/c_error.h"
8
9#include "global.hpp"
10
11namespace Cvb
12{
13
14 CVB_BEGIN_INLINE_NS
15
17 namespace ErrorCodes
18 {
19
21 const int CVB_OK = CExports::CVC_E_OK;
23 const int CVB_ERROR = static_cast<int>(CExports::CVC_E_ERROR | 0x80000000);
25 const int CVB_PARAMETER = static_cast<int>(CExports::CVC_E_PARAMETER | 0x80000000);
27 const int CVB_FILEIO = static_cast<int>(CExports::CVC_E_FILEIO | 0x80000000);
29 const int CVB_TIMEOUT = static_cast<int>(CExports::CVC_E_TIMEOUT | 0x80000000);
31 const int CVB_MEMORY = static_cast<int>(CExports::CVC_E_MEMORY | 0x80000000);
33 const int CVB_INVALIDPLANE = static_cast<int>(CExports::CVC_E_INVALIDPLANE | 0x80000000);
35 const int CVB_UNSUPPORTEDDATATYPE = static_cast<int>(CExports::CVC_E_UNSUPPORTEDDATATYPE | 0x80000000);
37 const int CVB_INVALIDCAMERAPORT = static_cast<int>(CExports::CVC_E_INVALIDCAMERAPORT | 0x80000000);
39 const int CVB_BOARDSELECT = static_cast<int>(CExports::CVC_E_BOARDSELECT | 0x80000000);
41 const int CVB_INVALIDTRIGGERMODE = static_cast<int>(CExports::CVC_E_INVALIDTRIGGERMODE | 0x80000000);
43 const int CVB_PROPERTYREAD = static_cast<int>(CExports::CVC_E_PROPERTYREAD | 0x80000000);
45 const int CVB_PROPERTYWRITE = static_cast<int>(CExports::CVC_E_PROPERTYWRITE | 0x80000000);
47 const int CVB_INVALIDPORT = static_cast<int>(CExports::CVC_E_INVALIDPORT | 0x80000000);
49 const int CVB_PORTREAD = static_cast<int>(CExports::CVC_E_PORTREAD | 0x80000000);
51 const int CVB_PORTWRITE = static_cast<int>(CExports::CVC_E_PORTWRITE | 0x80000000);
53 const int CVB_NOIMAGE = static_cast<int>(CExports::CVC_E_NOIMAGE | 0x80000000);
55 const int CVB_NOINTERFACE = static_cast<int>(CExports::CVC_E_NOINTERFACE | 0x80000000);
57 const int CVB_BUSY = static_cast<int>(CExports::CVC_E_BUSY | 0x80000000);
59 const int CVB_NOTSUPPORTED = static_cast<int>(CExports::CVC_E_NOTSUPPORTED | 0x80000000);
61 const int CVB_GRABABORTED = static_cast<int>(CExports::CVC_E_GRABABORTED | 0x80000000);
63 const int CVB_NOPIXELLIST = static_cast<int>(CExports::CVC_E_NOPIXELLIST | 0x80000000);
65 const int CVB_NOTENOUGHDATA = static_cast<int>(CExports::CVC_E_NOTENOUGHDATA | 0x80000000);
67 const int CVB_NOTRANSFORMATION = static_cast<int>(CExports::CVC_E_NOTRANSFORMATION | 0x80000000);
69 const int CVB_LINEAR_ONLY = static_cast<int>(CExports::CVC_E_LINEAR_ONLY | 0x80000000);
71 const int CVB_DIVISIONBYZERO = static_cast<int>(CExports::CVC_E_DIVISIONBYZERO | 0x80000000);
73 const int CVB_INVALIDDIMENSION = static_cast<int>(CExports::CVC_E_INVALIDDIMENSION | 0x80000000);
75 const int CVB_INVALIDCOLORMODEL = static_cast<int>(CExports::CVC_E_INVALIDCOLORMODEL | 0x80000000);
77 const int CVB_INVALIDDATATYPE = static_cast<int>(CExports::CVC_E_INVALIDDATATYPE | 0x80000000);
79 const int CVB_WRONGOBJECT = static_cast<int>(CExports::CVC_E_WRONGOBJECT | 0x80000000);
81 const int CVB_NOTREADY = static_cast<int>(CExports::CVC_E_NOTREADY | 0x80000000);
83 const int CVB_NOANGLE = static_cast<int>(CExports::CVC_E_NOANGLE | 0x80000000);
85 const int CVB_NOVECTOR2D = static_cast<int>(CExports::CVC_E_NOVECTOR2D | 0x80000000);
87 const int CVB_NOLINE2D = static_cast<int>(CExports::CVC_E_NOLINE2D | 0x80000000);
89 const int CVB_VECTOR2D_ZERO_LENGTH = static_cast<int>(CExports::CVC_E_VECTOR2D_ZERO_LENGTH | 0x80000000);
91 const int CVB_VECTORS_IDENTICAL = static_cast<int>(CExports::CVC_E_VECTORS_IDENTICAL | 0x80000000);
93 const int CVB_LINE2D_VERTICAL = static_cast<int>(CExports::CVC_E_LINE2D_VERTICAL | 0x80000000);
95 const int CVB_LINE2D_HORIZONTAL = static_cast<int>(CExports::CVC_E_LINE2D_HORIZONTAL | 0x80000000);
97 const int CVB_NOARGUMENT = static_cast<int>(CExports::CVC_E_NOARGUMENT | 0x80000000);
99 const int CVB_LINE2D_UNDEFINED = static_cast<int>(CExports::CVC_E_LINE2D_UNDEFINED | 0x80000000);
101 const int CVB_NOINTERSECTION = static_cast<int>(CExports::CVC_E_NOINTERSECTION | 0x80000000);
103 const int CVB_NOCLIPPING = static_cast<int>(CExports::CVC_E_NOCLIPPING | 0x80000000);
105 const int CVB_NOTENOUGHLINES = static_cast<int>(CExports::CVC_E_NOTENOUGHLINES | 0x80000000);
107 const int CVB_OVERFLOW = static_cast<int>(CExports::CVC_E_OVERFLOW | 0x80000000); // OVERFLOW clash with math.h
109 const int CVB_NOCIRCLE = static_cast<int>(CExports::CVC_E_NOCIRCLE | 0x80000000);
111 const int CVB_ACCESS = static_cast<int>(CExports::CVC_E_ACCESS | 0x80000000);
113 const int CVB_NOTPRESENT = static_cast<int>(CExports::CVC_E_NOTPRESENT | 0x80000000);
116 const int CVB_UNSUPPORTEDFEATURE = static_cast<int>(CExports::CVC_E_UNSUPPORTEDFEATURE | 0x80000000);
118 const int CVB_INVALIDINDEX = static_cast<int>(CExports::CVC_E_INVALIDINDEX | 0x80000000);
120 const int CVB_NOOVERLAY = static_cast<int>(CExports::CVC_E_NOOVERLAY | 0x80000000);
122 const int CVB_INVALIDSTATE = static_cast<int>(CExports::CVC_E_INVALIDSTATE | 0x80000000);
124 const int CVB_EMPTYRESULT = static_cast<int>(CExports::CVC_E_EMPTYRESULT | 0x80000000);
125
126 inline int FromRes(CExports::cvbres_t hr) noexcept
127 {
128 return static_cast<int>((hr) & 0x7FFFFFFF);
129 }
130
131 }; // namespace ErrorCodes
132
134
136 class CvbException : public std::runtime_error
137 {
138 public:
139 static std::exception_ptr FromCvbResult(int errorCode, const std::string &message) noexcept
140 {
141 switch (errorCode)
142 {
152
160
176
179
182
183 default:
184 return std::make_exception_ptr(CvbException(message, errorCode));
185 }
186 }
187
189
193 int ErrorCode() const noexcept
194 {
195 return errorCode_;
196 }
197
198 private:
199 CvbException(const std::string &message, int errorCode) noexcept
200 : std::runtime_error(message)
201 , errorCode_(errorCode)
202 {
203 }
204
205 int errorCode_ = 0;
206 };
207
208 CVB_END_INLINE_NS
209
210} // namespace Cvb
Special runtime exception to carry a native error code.
Definition exception.hpp:137
int ErrorCode() const noexcept
Get the classic API error code.
Definition exception.hpp:193
T make_exception_ptr(T... args)
Classic API error codes.
Definition exception.hpp:18
const int CVB_NOANGLE
Not an angle object.
Definition exception.hpp:83
const int CVB_INVALIDDATATYPE
Invalid data type.
Definition exception.hpp:77
const int CVB_PROPERTYWRITE
Property write error.
Definition exception.hpp:45
const int CVB_INVALIDCOLORMODEL
Invalid color model.
Definition exception.hpp:75
const int CVB_NOOVERLAY
Image that is expected to have overlay bits does not have overlay bits.
Definition exception.hpp:120
const int CVB_INVALIDSTATE
A state which does not allow to call a function.
Definition exception.hpp:122
const int CVB_NOTENOUGHLINES
Not enough lines to perform intersection.
Definition exception.hpp:105
const int CVB_PROPERTYREAD
Property read error.
Definition exception.hpp:43
const int CVB_BUSY
Hardware busy.
Definition exception.hpp:57
const int CVB_LINE2D_VERTICAL
Vertical line.
Definition exception.hpp:93
const int CVB_DIVISIONBYZERO
Division by zero was attempted.
Definition exception.hpp:71
const int CVB_NOCLIPPING
No clipping points available.
Definition exception.hpp:103
const int CVB_UNSUPPORTEDDATATYPE
Unsupported data type.
Definition exception.hpp:35
const int CVB_BOARDSELECT
Board select failed.
Definition exception.hpp:39
const int CVB_ERROR
Generic unspecified error.
Definition exception.hpp:23
const int CVB_NOPIXELLIST
Pointer was not pointing to a pixel list.
Definition exception.hpp:63
const int CVB_GRABABORTED
Failure because grab was aborted.
Definition exception.hpp:61
const int CVB_INVALIDDIMENSION
Invalid number of dimensions.
Definition exception.hpp:73
const int CVB_INVALIDPORT
Invalid port.
Definition exception.hpp:47
const int CVB_NOTREADY
Not ready for the requested operation.
Definition exception.hpp:81
const int CVB_LINE2D_UNDEFINED
Line 2D object has not yet been defined.
Definition exception.hpp:99
const int CVB_INVALIDINDEX
Index in an indexed access exceeded limits.
Definition exception.hpp:118
const int CVB_PORTWRITE
could not write port.
Definition exception.hpp:51
const int CVB_FILEIO
File I/O error.
Definition exception.hpp:27
const int CVB_NOTRANSFORMATION
The object passed to the function was not a NL-transformation object.
Definition exception.hpp:67
const int CVB_NOCIRCLE
Object is not a 2D circle.
Definition exception.hpp:109
const int CVB_EMPTYRESULT
The function returned an empty result, e.g. nullptr for an empty point cloud.
Definition exception.hpp:124
const int CVB_NOTENOUGHDATA
Too few data available for a calculation.
Definition exception.hpp:65
const int CVB_INVALIDTRIGGERMODE
Invalid trigger mode.
Definition exception.hpp:41
const int CVB_INVALIDCAMERAPORT
Invalid camera port.
Definition exception.hpp:37
const int CVB_LINEAR_ONLY
The function only works on linear images.
Definition exception.hpp:69
const int CVB_NOINTERSECTION
The lines provided to the function do not intersect.
Definition exception.hpp:101
const int CVB_NOVECTOR2D
Not a 2D vector object.
Definition exception.hpp:85
const int CVB_OK
No error occurred.
Definition exception.hpp:21
const int CVB_PARAMETER
Parameter error.
Definition exception.hpp:25
const int CVB_NOLINE2D
Not a 2D line object.
Definition exception.hpp:87
const int CVB_MEMORY
Memory allocation failed.
Definition exception.hpp:31
const int CVB_ACCESS
Access error.
Definition exception.hpp:111
const int CVB_NOINTERFACE
Interface not available.
Definition exception.hpp:55
const int CVB_VECTOR2D_ZERO_LENGTH
Vector has zero length.
Definition exception.hpp:89
const int CVB_WRONGOBJECT
Wrong object.
Definition exception.hpp:79
const int CVB_NOIMAGE
No image at all.
Definition exception.hpp:53
const int CVB_NOTSUPPORTED
A certain feature is not supported.
Definition exception.hpp:59
const int CVB_LINE2D_HORIZONTAL
Horizontal line.
Definition exception.hpp:95
const int CVB_INVALIDPLANE
Invalid plane used.
Definition exception.hpp:33
const int CVB_OVERFLOW
Input value was too big or did lead to a too big result.
Definition exception.hpp:107
const int CVB_NOARGUMENT
Argument cannot be calculated for x = y = 0.
Definition exception.hpp:97
const int CVB_TIMEOUT
Timeout in function.
Definition exception.hpp:29
const int CVB_UNSUPPORTEDFEATURE
Definition exception.hpp:116
const int CVB_VECTORS_IDENTICAL
Identical vectors.
Definition exception.hpp:91
const int CVB_PORTREAD
Could not read port.
Definition exception.hpp:49
const int CVB_NOTPRESENT
Not present.
Definition exception.hpp:113
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17