rasdaman complete source
error.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
33 #ifndef _D_ERROR_
34 #define _D_ERROR_
35 
36 //@ManMemo: Module: {\bf raslib}
37 
38 /*@Doc:
39 
40  This class implements partially the \Ref{r_Error} class of the
41  C++ binding of ODMG-93 v.1.2. It extends exception
42  handling through deriving special classes for MDD specific
43  errors.
44 
45  In future, \Ref{r_Error} should be derived from the class exception
46  defined in the C++ standard.
47 
48  The class allows the specification of an error number. The error number
49  is used as an index to a generic textual description of the error which
50  is read by {\tt setErrorTextOnNumber()}. Error text is loaded from a
51  text file by the friend method {\tt initTextTable()} which has to be
52  invoked at the beginning of the application. The table can be freed again
53  using {\tt freeTextTable()}.
54  The parameters in the generic text are substituted using {\tt setTextParameter()}.
55 
56  If no error number is specified, the error kind is used as error text.
57 
58  Attention: The content of an error object is not supposed to be changed after
59  creation because the error text is initialized only in the constructor. Therefore,
60  just read methods for error parameters are supported.
61 
62  A standard error text file is read by {\tt initTextTable()}. The location and file
63  name expected is defined here. Ideally all programs using this mechanism should
64  include error.hh to use the same settings.
65 */
66 
67 #ifdef __VISUALC__
68 #pragma warning( disable : 4290 )
69 #endif
70 
71 #include <exception>
72 
73 #include "raslib/mddtypes.hh"
74 #include <list>
75 
76 /*
77  * error text file ------------------
78  */
79 
81 #define ERRORTEXT_PATH "/bin"
82 
84 #define ERRORTEXT_FILE "errtxts"
85 
86 /* end error text file ------------------ */
87 
88 class r_Error : public std::exception
89 {
90 public:
91 
93  struct errorInfo
94  {
95  int num;
96  char kind;
97  char* text;
98  };
99 
101  enum kind { r_Error_General,
102  r_Error_DatabaseClassMismatch,
103  r_Error_DatabaseClassUndefined,
104  r_Error_DatabaseClosed,
105  r_Error_DatabaseOpen,
106  r_Error_DateInvalid,
107  r_Error_IteratorExhausted,
108  r_Error_NameNotUnique,
109  r_Error_QueryParameterCountInvalid,
110  r_Error_QueryParameterTypeInvalid,
111  r_Error_RefInvalid,
112  r_Error_RefNull,
113  r_Error_TimeInvalid,
114  r_Error_TimestampInvalid,
115  r_Error_TransactionOpen,
116  r_Error_TransactionNotOpen,
117  r_Error_TypeInvalid,
118 
119  r_Error_OIdInvalid,
120  r_Error_OIdNotUnique,
121 
122  r_Error_DatabaseUnknown,
123  r_Error_TransferFailed,
124  r_Error_HostInvalid,
125  r_Error_ServerInvalid,
126  r_Error_RpcInterfaceIncompatible,
127  r_Error_ClientUnknown,
128  r_Error_ObjectUnknown,
129  r_Error_ObjectInvalid,
130 
131  r_Error_QueryExecutionFailed,
132  r_Error_BaseDBMSFailed,
133  r_Error_CollectionElementTypeMismatch,
134  r_Error_CreatingOIdFailed,
135  r_Error_TransactionReadOnly,
136 
137  r_Error_LimitsMismatch,
138  r_Error_NameInvalid,
139  r_Error_FeatureNotSupported,
140  // r_Error_SerialisableException is used for subclasses which can be serialised
141  // as strings for client / server transfer
142  r_Error_SerialisableException,
143 
144  r_Error_AccesDenied,
145  r_Error_SystemOverloaded,
146 
147  r_Error_MemoryAllocation,
148 
149  r_Error_InvalidOptimizationLevel
150 
151  };
152 
154  r_Error();
155 
157  r_Error( const r_Error& );
158 
160  r_Error( kind the_kind, unsigned int newErrorNo = 0 );
161 
163  r_Error( unsigned int errorno );
164 
166  virtual ~r_Error() throw();
167 
169  virtual const char* what() const throw();
170 
172  const r_Error& operator=( const r_Error& obj );
173 
174  //@Man: Read/Write methods:
176  inline kind get_kind() const;
179  inline unsigned int get_errorno() const;
181 
182 
184  virtual char* serialiseError();
185  /*@Doc:
186  The char* returned is allocated with malloc (for potential RPC transfer) and has
187  to be freed by the caller.
188  */
189 
191  static r_Error* getAnyError(char* serErr);
192  /*@Doc:
193  Useful results can only be expected for errors of kind r_Error_SerialisableException.
194  */
195 
197  static void initTextTable();
198 
200  static void freeTextTable();
201 
203  void setTextParameter( const char* parameterName, int value );
204 
206  void setTextParameter( const char* parameterName, const char* value );
207 
208 protected:
210  void setErrorTextOnKind();
211 
213  void setErrorTextOnNumber();
214 
216  virtual void resetErrorText();
222  char* errorText;
224 
226  kind theKind;
227 
229  unsigned int errorNo;
230 
231 private:
232  static errorInfo *textList;
233 
234  /*
235  * list of error codes, contining numerical error code, error flag char
236  * (warning or error), and error text.
237  * It is modelled as nested pairs to allow using standard classes.
238  * Filled from file.
239  */
240  static std::list<std::pair<std::pair<int,char>, char*> > *errorTexts;
241  static bool errorTextsLoaded;
242 
243 };
244 
245 
246 /* Modified by Constantin Jucovschi */
247 /* Added the definition of the initTextTable() and freeTextTable()*/
248 // void initTextTable();
249 // void freeTextTable();
250 
251 
252 
253 //@ManMemo: Module: {\bf raslib}
254 
255 /*@Doc:
256 
257  This class represents an array object saying that the
258  result is no interval.
259 
260 */
261 
262 class r_Eno_interval : public r_Error
263 {
264 public:
266  r_Eno_interval();
267 };
268 
269 
270 
271 
272 //@ManMemo: Module: {\bf raslib}
273 
274 /*@Doc:
275 
276  This class represents an array object saying that the
277  specified index is not within the bounds.
278 
279 */
280 
281 class r_Eindex_violation : public r_Error
282 {
283 public:
285  r_Eindex_violation( r_Range dlow, r_Range dhigh, r_Range dindex );
286 
287 protected:
289  virtual void resetErrorText();
290 
291 private:
293  r_Range low;
295  r_Range high;
297  r_Range index;
298 };
299 
300 
301 
302 
303 //@ManMemo: Module: {\bf raslib}
304 
305 /*@Doc:
306 
307  This class represents an array object saying that the
308  dimensionalies of two objects do not match.
309 
310 */
311 
312 class r_Edim_mismatch : public r_Error
313 {
314 public:
316  r_Edim_mismatch( r_Dimension pdim1, r_Dimension pdim2 );
317 
318 protected:
320  virtual void resetErrorText();
321 
322 private:
324  r_Dimension dim1;
326  r_Dimension dim2;
327 };
328 
329 
330 
331 //@ManMemo: Module: {\bf raslib}
332 
333 /*@Doc:
334 
335  This class represents an error object saying that an
336  initialization overflow occured. This happens f.e. if the
337  stream input operator is invoked more often than the
338  object has dimensions.
339 
340 */
341 
342 class r_Einit_overflow : public r_Error
343 {
344 public:
346  r_Einit_overflow();
347 };
348 
349 
350 
351 //@ManMemo: Module: {\bf raslib}
352 
353 /*@Doc:
354 
355  This class represents an error object saying that the
356  result is no cell. This happens f.e. if the cast operator
357  for casting to the base type of class \Ref{r_Marray} is invoked
358  on an object which is not 'zero-dimensional'.
359 
360 */
361 
362 class r_Eno_cell : public r_Error
363 {
364 public:
366  r_Eno_cell();
367 };
368 
369 
370 
371 //@ManMemo: Module: {\bf raslib}
372 
373 /*@Doc:
374 
375  The class is used for errors occuring through query execution. In most cases, the position which
376  caused the error can be fixed. This position is specified by line number, column number, and
377  the token which is involved.
378  Additionally, the class is generic concerning the error type. Different error types can be specified
379  by stating the error number.
380 
381 */
382 
383 class r_Equery_execution_failed : public r_Error
384 {
385 public:
387  r_Equery_execution_failed( unsigned int errorno, unsigned int lineno, unsigned int columnno, const char* token );
388 
390  r_Equery_execution_failed( const r_Equery_execution_failed &err );
391 
393  ~r_Equery_execution_failed() throw();
394 
395  //@Man: Read methods:
397  inline unsigned int get_lineno() const;
400  inline unsigned int get_columnno() const;
402  inline const char* get_token() const;
404 
405 
406 protected:
408  virtual void resetErrorText();
409 
410 private:
412  unsigned int lineNo;
413 
415  unsigned int columnNo;
416 
418  char* token;
419 };
420 
421 
422 
423 //@ManMemo: Module: {\bf raslib}
424 
425 /*@Doc:
426 
427  This class represents an error when the limits reported on the same
428  object (array) by two sources do not match (at least in one end).
429 */
430 
431 class r_Elimits_mismatch : public r_Error
432 {
433 public:
435  r_Elimits_mismatch( r_Range lim1, r_Range lim2 );
436 
437 protected:
439  virtual void resetErrorText();
440 
441 private:
443  r_Range i1;
445  r_Range i2;
446 };
447 
448 //@ManMemo: Module: {\bf raslib}
449 
450 /*@Doc:
451  This class represents an error in the base DBMS. It stores the error
452  number in the base DBMS and the error text of the base DBMS. The
453  interpretation of the error is specific for the base DBMS. The
454  errtxt mechanism of RasDaMan is not used, instead what() returns the
455  error of the base DBMS. Note that the const char* parameters of the
456  constructor are not copied, but the pointers are stored. They are
457  never freed (to enable use of constants).
458 */
459 
460 class r_Ebase_dbms : public r_Error
461 {
462 public:
464  r_Ebase_dbms( const long& newErrNum, const char* newErrTxt );
465 
467  r_Ebase_dbms( const r_Ebase_dbms& oldErr );
468 
470  r_Ebase_dbms( kind newTheKind, unsigned long newErrNum, const char* myStr );
471 
473  ~r_Ebase_dbms() throw();
474 
476  const r_Ebase_dbms& operator=( const r_Ebase_dbms& obj );
477 
478  // overloads from r_Error
479  virtual const char* what() const throw();
480  virtual char* serialiseError();
481 
482 private:
483 
485  void buildWhat();
487  char* baseDBMS;
489  long dbmsErrNum;
491  char* dbmsErrTxt;
493  char* whatTxt;
494 };
495 
496 class r_Eno_permission : public r_Error
497 {
498 public:
499  r_Eno_permission();
500 
501 };
502 
503 class r_Ecapability_refused : public r_Error
504 {
505 public:
506  r_Ecapability_refused();
507 
508 };
509 
510 class r_Ememory_allocation: public r_Error
511 {
512 public:
513  r_Ememory_allocation();
514 };
515 
516 #define MEMMORYALLOCATIONERROR 66
517 #define INTERNALDLPARSEERROR 100
518 #define NOPOINT 200
519 #define RASTYPEUNKNOWN 209
520 #define BASETYPENOTSUPPORTED 210
521 #define RPCCOMMUNICATIONFAILURE 212
522 #define SYSTEM_COLLECTION_NOT_WRITABLE 216
523 #define SYSTEM_COLLECTION_HAS_NO_OID 217
524 #define CONVERSIONFORMATNOTSUPPORTED 218
525 #define TILESIZETOOSMALL 219
526 #define STORAGERLAYOUTINCOMPATIBLEWITHGMARRAY 220
527 #define DOMAINUNINITIALISED 221
528 #define NOTANMARRAYTYPE 222
529 #define RCINDEXWITHINCOMPATIBLEMARRAYTYPE 223
530 #define TILECONFIGMARRAYINCOMPATIBLE 224
531 #define RCINDEXWITHOUTREGULARTILING 225
532 #define UDFBODYTOOLARGE 226
533 #define POLYGONWRONGPOINTDIMENSION 227
534 #define POLYGONWRONGINITSTRING 228
535 #define QUERYPARAMETERINVALID 229
536 #define ILLEGALARGUMENT 230
537 #define MARRAYHASNOBASETYPE 231
538 #define INTERVALOPEN 232
539 #define INTERVALSWITHDIFFERENTDIMENSION 233
540 #define TILINGPARAMETERNOTCORRECT 234
541 #define CONNECTIONCLOSED 235
542 #define COMPRESSIONFAILED 236
543 #define CLIENTCOMMUICATIONFAILURE 237
544 #define BASETYPENOTSUPPORTEDBYOPERATION 238
545 #define OVERLAYPATTERNTOOSMALL 239
546 #define INSERTINTORCINDEX 240
547 #define NOTILINGDEFINED 241
548 #define UNSATIFIEDMDDCONSTANT 373
549 #define DATABASE_EXISTS 708
550 #define NO_PERMISSION_FOR_OPERATION 803
551 #define CAPABILITY_REFUSED 804
552 #define DATABASE_INCONSISTENT 1000
553 #define DATABASE_INCOMPATIBLE 1001
554 #define ZERO_LENGTH_BLOB 1002
555 #define TILE_CONTAINER_NOT_FOUND 1003
556 #define INDEX_OF_MDD_IS_NULL 1004
557 #define STORAGE_OF_MDD_IS_NULL 1005
558 #define UNKNOWN_INDEX_TYPE 1006
559 #define ILLEGAL_INDEX_TYPE 1007
560 #define COLLTYPE_NULL 1008
561 #define MDD_NOT_VALID 1009
562 #define MDDTYPE_NULL 1010
563 #define ILLEGALSTATEREACHED 1011
564 #define COLLECTIONTYPEISNULL 1012
565 #define TYPENAMEISTOOLONG 1013
566 #define INVALIDOBJECTNAME 1014
567 #define DATABASE_OPEN 2000
568 #define INVALID_OIDTYPE 2001
569 #define STRUCTTYPE_ELEMENT_UNKNOWN 2002
570 #define STRUCTTYPE_ELEMENT_OUT_OF_BOUNDS 2003
571 #define TRANSIENT_INDEX_USED_AS_PERSISTENT 2004
572 #define TILE_MULTIPLE_TIMES_RETRIEVED 2005
573 #define TILE_NOT_INSERTED_INTO_INDEX 2006
574 #define TRANSIENT_INDEX_OUT_OF_BOUNDS 2007
575 #define MDD_EXISTS_MULTIPLE_TIMES 2008
576 #define DATA_NOT_INSERTED_COMPLETELY 2009
577 #define CONVERSION_RETURNED_WRONG_TYPE 2010
578 #define COLLECTIONTYPEHASNOELEMENTTYPE 2011
579 #define MARRAYTYPEHASNOELEMENTTYPE 2012
580 #define PROPERTYTYPEHASNOELEMENTTYPE 2013
581 #define SCALARWASPASSEDNULLTYPE 2014
582 #define INDEXNOTFOUNDINPARENT 2015
583 #define INDEXEXHAUSTEDAREA 2016
584 #define LAYOUTALGORITHMPROBLEM 2017
585 #define OBJECTDOESNOTSUPPORTSWAPING 2018
586 #define ERRORDURINGSWAPING 2019
587 #define BINARYEXPORTNOTSUPPORTEDFOROBJECT 2020
588 #define BINARYIMPORTNOTSUPPORTEDFOROBJECT 2021
589 #define OPERANDSRESULTTYPESNOMATCH 2022
590 #define TRYINGTOINFERHOOKFROMNULLNODE 2023
591 #define QTNODETYPEPARENTDOESNOTEXIST 2024
592 
593 #include "raslib/error.icc"
594 
595 #endif