| RDB 2

error.hpp
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 *
4 * Copyright 2025 RIEGL Laser Measurement Systems
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * SPDX-License-Identifier: Apache-2.0
19 *
20 *******************************************************************************
21 */
22 /*!
23 *******************************************************************************
24 *
25 * \file error.hpp
26 * \author RIEGL LMS GmbH, Austria
27 * \brief Database error signaling/handling
28 * \version 2015-10-14/AW: Initial version
29 * \version 2017-11-09/AW: Error 'PointAttributeNotMergeable' added
30 * \version 2017-11-24/AW: Constructors declared as "explicit" (#2825)
31 * \version 2018-03-12/AW: Error 'PointAttributeInvalidInvalid' added (#3047)
32 * \version 2018-11-20/AW: Error 'QueryInsertTooManyPoints' added (#3215)
33 * \version 2019-05-13/AW: Error 'MetadataInvalidName' added
34 * \version 2020-02-14/AW: Error 'MetadataTableTooLarge' added (#3560)
35 * \version 2020-02-21/AW: Class 'Error' is now context-free (#3544)
36 * \version 2020-03-30/AW: Error 'MetadataSignatureError' added (#3570)
37 * \version 2021-06-02/AW: Error 'TransactionDetailsTooLarge' added (#3905)
38 * \version 2021-06-02/AW: Error 'InvalidStringSize' added (#3905)
39 * \version 2024-11-29/AW: Error 'QueryInsertFailed' added (#5339)
40 *
41 *******************************************************************************
42 */
43
44 #ifndef RIEGL_RDB_ERROR_HPP
45 #define RIEGL_RDB_ERROR_HPP
46
47 //---< INCLUDES >---------------------------------------------------------------
48
49 #include <string>
50 #include <exception>
51 #include "riegl/rdb.h"
52
53 //---< NAMESPACE >--------------------------------------------------------------
54
55 namespace riegl {
56 namespace rdb {
57
58 //---< CLASS Error >------------------------------------------------------------
59 /*!
60 * \brief Database error class
61 */
62 class Error: public std::exception
63 {
64 public:
65 /*!
66 * \brief List of error codes
67 */
68 enum ErrorCode
69 {
70 DatabaseOpenFailed = 10100, //!< failed to create or open database, most likely insufficient access rights or invalid location
71 DatabaseNotOpened = 10101, //!< a query failed because no database was opened
72 DatabaseNotWritable = 10102, //!< modification of database not possible as opened in read-only mode (check file access rights)
73 DatabaseVersionNotSupported = 10103, //!< database file format version not supported
74 DatabaseSchemaValidationFailed = 10104, //!< database does not correspond to user-supplied schema
75 //
76 TransactionMissing = 10201, //!< operation failed because there was no transaction, see pointcloud::Transactions::begin()
77 TransactionPending = 10202, //!< operation failed because a transaction is started but not yet finished
78 TransactionCorrupted = 10203, //!< operation failed because database was modified by concurrent client (should never happen)
79 TransactionInvalid = 10204, //!< given transaction ID is invalid
80 TransactionLockAcquireFailed = 10205, //!< failed to acquire database transaction lock
81 TransactionLockReleaseFailed = 10206, //!< failed to release database transaction lock
82 TransactionDetailsTooLarge = 10207, //!< total size of all transaction details strings exceeds the limit
83 //
84 PointAttributeDuplicate = 10301, //!< point attribute of given name already exists
85 PointAttributeMissing = 10302, //!< point attribute of given name does not exist, attribute name is stored in error details
86 PointAttributeInvalidLength = 10303, //!< point attribute vector length is invalid
87 PointAttributeInvalidLimits = 10304, //!< point attribute minimum and maximum are invalid
88 PointAttributeInvalidDefault = 10305, //!< point attribute default value out of range (min./max.)
89 PointAttributeInvalidResolution = 10306, //!< point attribute resolution is invalid
90 PointAttributeCannotDuplicate = 10307, //!< source point attribute data could not be copied to target point attribute data as they are not compatible
91 PointAttributeCannotModify = 10308, //!< modification of point attribute property not allowed (property name is stored in error details)
92 PointAttributeInvalidScale = 10309, //!< invalid point attribute scale factor given (value is stored in error details)
93 PointAttributeNotMergeable = 10310, //!< the point attribute details can not be merged because they are not compatible (reason see details) \see riegl::rdb::pointcloud::PointAttributes::getMerged()
94 PointAttributeInvalidInvalid = 10311, //!< point attribute invalid value out of range (min./max.)
95 //
96 MetadataValidationFailed = 10312, //!< metadata entry does not correspond to schema
97 MetadataInvalidName = 10313, //!< metadata entry name is not allowed (name is stored in error details)
98 MetadataTableTooLarge = 10314, //!< total size of all metadata item names and values exceeds the limit
99 MetadataSignatureError = 10315, //!< failed to create or verify metadata entry signature (reason in error details)
100 //
101 QueryBindAttributeInvalid = 10401, //!< bound invalid attribute to query, attribute name is stored in error details (not all attributes are allowed in all queries)
102 QueryBindAttributeUnknown = 10402, //!< bound unknown attribute to query, attribute name is stored in error details
103 QueryBindAttributeIndexVoid = 10403, //!< bound attribute with invalid vector index
104 QueryBindAttributeBufferVoid = 10404, //!< bound attribute buffer is invalid
105 QuerySelectFilterParseFailed = 10406, //!< select query filter string parsing failed, check syntax
106 QuerySelectAttributeUnknown = 10407, //!< select query filter string refers to unknown point attribute, attribute name is stored in error details
107 QuerySelectVectorIndexMissing = 10408, //!< select query filter string does not define vector index for vector point attribute
108 QuerySelectVectorIndexInvalid = 10409, //!< select query filter string contains invalid vector attribute index
109 QuerySelectGraphNodeInvalid = 10410, //!< select query node ID invalid
110 QueryInsertNoPrimaryAttribute = 10411, //!< no buffer for primary point attribute defined
111 QueryUpdateConstantAttribute = 10412, //!< tried to modify a constant attribute
112 QueryStatIndexNodeNotFound = 10413, //!< index graph node not found (invalid node ID)
113 QueryAttributeValueOutOfRange = 10414, //!< given attribute value (insert or update) is out of range, attribute name is stored in error details
114 QueryPointIdentifierMissing = 10415, //!< no buffer for point ID attribute defined
115 QueryPending = 10416, //!< can't start a new query as an other query started by this Pointcloud instance is not finished yet
116 QueryBindAttributeIncomplete = 10417, //!< no buffer given for at least one element of an vector point attribute (i.e. when length > 1)
117 QueryInsertTooManyPoints = 10418, //!< points can not be inserted as the total number of points would exceed the limit of 65536 * points-per-chunk (defined at database creation); this limit only applies if the primary point attribute is "riegl.id" (point ID)
118 QueryInsertFailed = 10419, //!< point insertion query failed, check the error details for the reason
119 //
120 FeatureNotLicensed = 10001, //!< no valid license key found for requested feature
121 FailedToParseJSON = 10002, //!< failed to parse JSON string, reason available in error details
122 InvalidStringSize = 10003, //!< invalid string size, string name and limit in error details
123 Internal = 90000, //!< base error code for fatal internal errors
124 Unknown = 1 //!< unknown error occurred
125 };
126
127 public:
128 explicit Error(
129 const int &code, //!< error code \see enum ErrorCode
130 const std::string &details = "" //!< optional error details (e.g. attribute name)
131 ); //!< Constructor
132
133 virtual ~Error(); //!< Destructor
134
135 /*!
136 * \brief Get error code
137 *
138 * \see enum ErrorCode
139 */
140 virtual const int& code() const RDB_NO_EXCEPT;
141
142 /*!
143 * \brief Get error text
144 *
145 * This function returns a basic English description text for the
146 * error. The client application might use this in e.g. error logs.
147 * Text that is displayed to the user should rather be derived from
148 * the error code instead (e.g. localized error messages).
149 */
150 virtual const char* what() const RDB_NO_EXCEPT;
151
152 /*!
153 * \brief Get error details
154 *
155 * Depending on the error code, there might be additional error details.
156 * For example, error QueryAttributeValueOutOfRange stores the attribute
157 * name in the error details.
158 *
159 * To see which errors provide details, \see enum ErrorCode.
160 */
161 virtual const char* details() const RDB_NO_EXCEPT;
162
163 private:
164 const int errorCode; //!< see constructor
165 const std::string errorDetails; //!< see constructor
166 };
167
168 }} // namespace riegl::rdb
169
170 #endif // RIEGL_RDB_ERROR_HPP
riegl::rdb::Error::what
virtual const char * what() const RDB_NO_EXCEPT
Get error text.
riegl::rdb::Error::PointAttributeInvalidScale
invalid point attribute scale factor given (value is stored in error details)
Definition: error.hpp:92
riegl::rdb::Error::InvalidStringSize
invalid string size, string name and limit in error details
Definition: error.hpp:122
riegl::rdb::Error::QueryBindAttributeIndexVoid
bound attribute with invalid vector index
Definition: error.hpp:103
riegl::rdb::Error::TransactionInvalid
given transaction ID is invalid
Definition: error.hpp:79
riegl::rdb::Error::PointAttributeDuplicate
point attribute of given name already exists
Definition: error.hpp:84
riegl::rdb::Error::PointAttributeCannotDuplicate
source point attribute data could not be copied to target point attribute data as they are not compat...
Definition: error.hpp:90
riegl::rdb::Error::DatabaseNotOpened
a query failed because no database was opened
Definition: error.hpp:71
riegl::rdb::Error::DatabaseOpenFailed
failed to create or open database, most likely insufficient access rights or invalid location ...
Definition: error.hpp:70
riegl::rdb::Error::TransactionLockReleaseFailed
failed to release database transaction lock
Definition: error.hpp:81
riegl::rdb::Error::PointAttributeInvalidLimits
point attribute minimum and maximum are invalid
Definition: error.hpp:87
riegl::rdb::Error::PointAttributeInvalidDefault
point attribute default value out of range (min./max.)
Definition: error.hpp:88
riegl::rdb::Error::TransactionCorrupted
operation failed because database was modified by concurrent client (should never happen) ...
Definition: error.hpp:78
std
Definition: graphNode.hpp:101
riegl::rdb::Error::DatabaseNotWritable
modification of database not possible as opened in read-only mode (check file access rights) ...
Definition: error.hpp:72
riegl::rdb::Error::QuerySelectVectorIndexInvalid
select query filter string contains invalid vector attribute index
Definition: error.hpp:108
riegl::rdb::Error::ErrorCode
ErrorCode
List of error codes.
Definition: error.hpp:68
riegl::rdb::Error::TransactionLockAcquireFailed
failed to acquire database transaction lock
Definition: error.hpp:80
riegl::rdb::Error::Unknown
unknown error occurred
Definition: error.hpp:124
riegl::rdb::Error::PointAttributeNotMergeable
the point attribute details can not be merged because they are not compatible (reason see details) ...
Definition: error.hpp:93
riegl::rdb::Error::QuerySelectGraphNodeInvalid
select query node ID invalid
Definition: error.hpp:109
riegl::rdb::Error::MetadataValidationFailed
metadata entry does not correspond to schema
Definition: error.hpp:96
riegl::rdb::Error::QueryInsertFailed
point insertion query failed, check the error details for the reason
Definition: error.hpp:118
riegl::rdb::Error::PointAttributeInvalidLength
point attribute vector length is invalid
Definition: error.hpp:86
riegl::rdb::Error::QuerySelectAttributeUnknown
select query filter string refers to unknown point attribute, attribute name is stored in error detai...
Definition: error.hpp:106
riegl::rdb::Error::QueryStatIndexNodeNotFound
index graph node not found (invalid node ID)
Definition: error.hpp:112
riegl::rdb::Error::PointAttributeMissing
point attribute of given name does not exist, attribute name is stored in error details ...
Definition: error.hpp:85
riegl::rdb::Error::TransactionPending
operation failed because a transaction is started but not yet finished
Definition: error.hpp:77
riegl
RIEGL Laser Measurement Systems GmbH, Austria.
Definition: context.hpp:48
riegl::rdb::Error::QueryUpdateConstantAttribute
tried to modify a constant attribute
Definition: error.hpp:111
riegl::rdb::Error::QueryBindAttributeInvalid
bound invalid attribute to query, attribute name is stored in error details (not all attributes are a...
Definition: error.hpp:101
riegl::rdb::Error::TransactionDetailsTooLarge
total size of all transaction details strings exceeds the limit
Definition: error.hpp:82
riegl::rdb::Error::QueryAttributeValueOutOfRange
given attribute value (insert or update) is out of range, attribute name is stored in error details ...
Definition: error.hpp:113
riegl::rdb::Error::PointAttributeInvalidInvalid
point attribute invalid value out of range (min./max.)
Definition: error.hpp:94
riegl::rdb::Error::PointAttributeInvalidResolution
point attribute resolution is invalid
Definition: error.hpp:89
riegl::rdb::Error::DatabaseSchemaValidationFailed
database does not correspond to user-supplied schema
Definition: error.hpp:74
riegl::rdb::Error::QueryBindAttributeUnknown
bound unknown attribute to query, attribute name is stored in error details
Definition: error.hpp:102
riegl::rdb::Error::QueryInsertNoPrimaryAttribute
no buffer for primary point attribute defined
Definition: error.hpp:110
riegl::rdb::Error::QueryBindAttributeIncomplete
no buffer given for at least one element of an vector point attribute (i.e. when length > 1) ...
Definition: error.hpp:116
riegl::rdb::Error::MetadataTableTooLarge
total size of all metadata item names and values exceeds the limit
Definition: error.hpp:98
riegl::rdb::Error::PointAttributeCannotModify
modification of point attribute property not allowed (property name is stored in error details) ...
Definition: error.hpp:91
riegl::rdb::Error::FeatureNotLicensed
no valid license key found for requested feature
Definition: error.hpp:120
riegl::rdb::Error::QueryPointIdentifierMissing
no buffer for point ID attribute defined
Definition: error.hpp:114
riegl::rdb::Error::Error
Error(const int &code, const std::string &details="")
Constructor.
riegl::rdb::Error::code
virtual const int & code() const RDB_NO_EXCEPT
Get error code.
riegl::rdb::Error::MetadataSignatureError
failed to create or verify metadata entry signature (reason in error details)
Definition: error.hpp:99
riegl::rdb::Error
Database error class.
Definition: error.hpp:62
riegl::rdb::Error::QueryBindAttributeBufferVoid
bound attribute buffer is invalid
Definition: error.hpp:104
riegl::rdb::Error::details
virtual const char * details() const RDB_NO_EXCEPT
Get error details.
riegl::rdb::Error::TransactionMissing
operation failed because there was no transaction, see pointcloud::Transactions::begin() ...
Definition: error.hpp:76
riegl::rdb::Error::MetadataInvalidName
metadata entry name is not allowed (name is stored in error details)
Definition: error.hpp:97
riegl::rdb::Error::QuerySelectVectorIndexMissing
select query filter string does not define vector index for vector point attribute ...
Definition: error.hpp:107
riegl::rdb::Error::QueryPending
can&#39;t start a new query as an other query started by this Pointcloud instance is not finished yet ...
Definition: error.hpp:115
riegl::rdb::Error::Internal
base error code for fatal internal errors
Definition: error.hpp:123
riegl::rdb::Error::FailedToParseJSON
failed to parse JSON string, reason available in error details
Definition: error.hpp:121
riegl::rdb::Error::~Error
virtual ~Error()
Destructor.
riegl::rdb::Error::QueryInsertTooManyPoints
points can not be inserted as the total number of points would exceed the limit of 65536 * points-per...
Definition: error.hpp:117
riegl::rdb::Error::QuerySelectFilterParseFailed
select query filter string parsing failed, check syntax
Definition: error.hpp:105
riegl::rdb::Error::DatabaseVersionNotSupported
database file format version not supported
Definition: error.hpp:73