RDB 2
error.hpp
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  *
4  * Copyright 2023 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  *
40  *******************************************************************************
41  */
42 
43 #ifndef RIEGL_RDB_ERROR_HPP
44 #define RIEGL_RDB_ERROR_HPP
45 
46 //---< INCLUDES >---------------------------------------------------------------
47 
48 #include <string>
49 #include <exception>
50 #include "riegl/rdb.h"
51 
52 //---< NAMESPACE >--------------------------------------------------------------
53 
54 namespace riegl {
55 namespace rdb {
56 
57 //---< CLASS Error >------------------------------------------------------------
58 /*!
59  * \brief Database error class
60  */
61 class Error: public std::exception
62 {
63 public:
64  /*!
65  * \brief List of error codes
66  */
67  enum ErrorCode
68  {
69  DatabaseOpenFailed = 10100, //!< failed to create or open database, most likely insufficient access rights or invalid location
70  DatabaseNotOpened = 10101, //!< a query failed because no database was opened
71  DatabaseNotWritable = 10102, //!< modification of database not possible as opened in read-only mode (check file access rights)
72  DatabaseVersionNotSupported = 10103, //!< database file format version not supported
73  DatabaseSchemaValidationFailed = 10104, //!< database does not correspond to user-supplied schema
74  //
75  TransactionMissing = 10201, //!< operation failed because there was no transaction, see pointcloud::Transactions::begin()
76  TransactionPending = 10202, //!< operation failed because a transaction is started but not yet finished
77  TransactionCorrupted = 10203, //!< operation failed because database was modified by concurrent client (should never happen)
78  TransactionInvalid = 10204, //!< given transaction ID is invalid
79  TransactionLockAcquireFailed = 10205, //!< failed to acquire database transaction lock
80  TransactionLockReleaseFailed = 10206, //!< failed to release database transaction lock
81  TransactionDetailsTooLarge = 10207, //!< total size of all transaction details strings exceeds the limit
82  //
83  PointAttributeDuplicate = 10301, //!< point attribute of given name already exists
84  PointAttributeMissing = 10302, //!< point attribute of given name does not exist, attribute name is stored in error details
85  PointAttributeInvalidLength = 10303, //!< point attribute vector length is invalid
86  PointAttributeInvalidLimits = 10304, //!< point attribute minimum and maximum are invalid
87  PointAttributeInvalidDefault = 10305, //!< point attribute default value out of range (min./max.)
88  PointAttributeInvalidResolution = 10306, //!< point attribute resolution is invalid
89  PointAttributeCannotDuplicate = 10307, //!< source point attribute data could not be copied to target point attribute data as they are not compatible
90  PointAttributeCannotModify = 10308, //!< modification of point attribute property not allowed (property name is stored in error details)
91  PointAttributeInvalidScale = 10309, //!< invalid point attribute scale factor given (value is stored in error details)
92  PointAttributeNotMergeable = 10310, //!< the point attribute details can not be merged because they are not compatible (reason see details) \see riegl::rdb::pointcloud::PointAttributes::getMerged()
93  PointAttributeInvalidInvalid = 10311, //!< point attribute invalid value out of range (min./max.)
94  //
95  MetadataValidationFailed = 10312, //!< metadata entry does not correspond to schema
96  MetadataInvalidName = 10313, //!< metadata entry name is not allowed (name is stored in error details)
97  MetadataTableTooLarge = 10314, //!< total size of all metadata item names and values exceeds the limit
98  MetadataSignatureError = 10315, //!< failed to create or verify metadata entry signature (reason in error details)
99  //
100  QueryBindAttributeInvalid = 10401, //!< bound invalid attribute to query, attribute name is stored in error details (not all attributes are allowed in all queries)
101  QueryBindAttributeUnknown = 10402, //!< bound unknown attribute to query, attribute name is stored in error details
102  QueryBindAttributeIndexVoid = 10403, //!< bound attribute with invalid vector index
103  QueryBindAttributeBufferVoid = 10404, //!< bound attribute buffer is invalid
104  QuerySelectFilterParseFailed = 10406, //!< select query filter string parsing failed, check syntax
105  QuerySelectAttributeUnknown = 10407, //!< select query filter string refers to unknown point attribute, attribute name is stored in error details
106  QuerySelectVectorIndexMissing = 10408, //!< select query filter string does not define vector index for vector point attribute
107  QuerySelectVectorIndexInvalid = 10409, //!< select query filter string contains invalid vector attribute index
108  QuerySelectGraphNodeInvalid = 10410, //!< select query node ID invalid
109  QueryInsertNoPrimaryAttribute = 10411, //!< no buffer for primary point attribute defined
110  QueryUpdateConstantAttribute = 10412, //!< tried to modify a constant attribute
111  QueryStatIndexNodeNotFound = 10413, //!< index graph node not found (invalid node ID)
112  QueryAttributeValueOutOfRange = 10414, //!< given attribute value (insert or update) is out of range, attribute name is stored in error details
113  QueryPointIdentifierMissing = 10415, //!< no buffer for point ID attribute defined
114  QueryPending = 10416, //!< can't start a new query as an other query started by this Pointcloud instance is not finished yet
115  QueryBindAttributeIncomplete = 10417, //!< no buffer given for at least one element of an vector point attribute (i.e. when length > 1)
116  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)
117  //
118  FeatureNotLicensed = 10001, //!< no valid license key found for requested feature
119  FailedToParseJSON = 10002, //!< failed to parse JSON string, reason available in error details
120  InvalidStringSize = 10003, //!< invalid string size, string name and limit in error details
121  Internal = 90000, //!< base error code for fatal internal errors
122  Unknown = 1 //!< unknown error occurred
123  };
124 
125 public:
126  explicit Error(
127  const int &code, //!< error code \see enum ErrorCode
128  const std::string &details = "" //!< optional error details (e.g. attribute name)
129  ); //!< Constructor
130 
131  virtual ~Error(); //!< Destructor
132 
133  /*!
134  * \brief Get error code
135  *
136  * \see enum ErrorCode
137  */
138  virtual const int& code() const RDB_NO_EXCEPT;
139 
140  /*!
141  * \brief Get error text
142  *
143  * This function returns a basic English description text for the
144  * error. The client application might use this in e.g. error logs.
145  * Text that is displayed to the user should rather be derived from
146  * the error code instead (e.g. localized error messages).
147  */
148  virtual const char* what() const RDB_NO_EXCEPT;
149 
150  /*!
151  * \brief Get error details
152  *
153  * Depending on the error code, there might be additional error details.
154  * For example, error QueryAttributeValueOutOfRange stores the attribute
155  * name in the error details.
156  *
157  * To see which errors provide details, \see enum ErrorCode.
158  */
159  virtual const char* details() const RDB_NO_EXCEPT;
160 
161 private:
162  const int errorCode; //!< see constructor
163  const std::string errorDetails; //!< see constructor
164 };
165 
166 }} // namespace riegl::rdb
167 
168 #endif // RIEGL_RDB_ERROR_HPP
virtual const char * what() const RDB_NO_EXCEPT
Get error text.
invalid point attribute scale factor given (value is stored in error details)
Definition: error.hpp:91
invalid string size, string name and limit in error details
Definition: error.hpp:120
bound attribute with invalid vector index
Definition: error.hpp:102
given transaction ID is invalid
Definition: error.hpp:78
point attribute of given name already exists
Definition: error.hpp:83
source point attribute data could not be copied to target point attribute data as they are not compat...
Definition: error.hpp:89
a query failed because no database was opened
Definition: error.hpp:70
failed to create or open database, most likely insufficient access rights or invalid location ...
Definition: error.hpp:69
failed to release database transaction lock
Definition: error.hpp:80
point attribute minimum and maximum are invalid
Definition: error.hpp:86
point attribute default value out of range (min./max.)
Definition: error.hpp:87
operation failed because database was modified by concurrent client (should never happen) ...
Definition: error.hpp:77
modification of database not possible as opened in read-only mode (check file access rights) ...
Definition: error.hpp:71
select query filter string contains invalid vector attribute index
Definition: error.hpp:107
ErrorCode
List of error codes.
Definition: error.hpp:67
failed to acquire database transaction lock
Definition: error.hpp:79
unknown error occurred
Definition: error.hpp:122
the point attribute details can not be merged because they are not compatible (reason see details) ...
Definition: error.hpp:92
select query node ID invalid
Definition: error.hpp:108
metadata entry does not correspond to schema
Definition: error.hpp:95
point attribute vector length is invalid
Definition: error.hpp:85
select query filter string refers to unknown point attribute, attribute name is stored in error detai...
Definition: error.hpp:105
index graph node not found (invalid node ID)
Definition: error.hpp:111
point attribute of given name does not exist, attribute name is stored in error details ...
Definition: error.hpp:84
operation failed because a transaction is started but not yet finished
Definition: error.hpp:76
RIEGL Laser Measurement Systems GmbH, Austria.
Definition: context.hpp:48
tried to modify a constant attribute
Definition: error.hpp:110
bound invalid attribute to query, attribute name is stored in error details (not all attributes are a...
Definition: error.hpp:100
total size of all transaction details strings exceeds the limit
Definition: error.hpp:81
given attribute value (insert or update) is out of range, attribute name is stored in error details ...
Definition: error.hpp:112
point attribute invalid value out of range (min./max.)
Definition: error.hpp:93
point attribute resolution is invalid
Definition: error.hpp:88
database does not correspond to user-supplied schema
Definition: error.hpp:73
bound unknown attribute to query, attribute name is stored in error details
Definition: error.hpp:101
no buffer for primary point attribute defined
Definition: error.hpp:109
no buffer given for at least one element of an vector point attribute (i.e. when length > 1) ...
Definition: error.hpp:115
total size of all metadata item names and values exceeds the limit
Definition: error.hpp:97
modification of point attribute property not allowed (property name is stored in error details) ...
Definition: error.hpp:90
no valid license key found for requested feature
Definition: error.hpp:118
no buffer for point ID attribute defined
Definition: error.hpp:113
Error(const int &code, const std::string &details="")
Constructor.
virtual const int & code() const RDB_NO_EXCEPT
Get error code.
failed to create or verify metadata entry signature (reason in error details)
Definition: error.hpp:98
Database error class.
Definition: error.hpp:61
bound attribute buffer is invalid
Definition: error.hpp:103
virtual const char * details() const RDB_NO_EXCEPT
Get error details.
operation failed because there was no transaction, see pointcloud::Transactions::begin() ...
Definition: error.hpp:75
metadata entry name is not allowed (name is stored in error details)
Definition: error.hpp:96
select query filter string does not define vector index for vector point attribute ...
Definition: error.hpp:106
can&#39;t start a new query as an other query started by this Pointcloud instance is not finished yet ...
Definition: error.hpp:114
base error code for fatal internal errors
Definition: error.hpp:121
failed to parse JSON string, reason available in error details
Definition: error.hpp:119
virtual ~Error()
Destructor.
points can not be inserted as the total number of points would exceed the limit of 65536 * points-per...
Definition: error.hpp:116
select query filter string parsing failed, check syntax
Definition: error.hpp:104
database file format version not supported
Definition: error.hpp:72