source: main/trunk/greenstone2/build-src/packages/isis-gdl/IErrors.cpp@ 26670

Last change on this file since 26670 was 6127, checked in by mdewsnip, 20 years ago

IsisGdl package for reading CDS/ISIS databases. Provided by Jean-Claude Dauphin at UNESCO, and modified slightly to compile and run under Linux.

  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/**********************************************************************
2 *
3 * IErrors.cpp
4 * Copyright (C) 2003 UNESCO
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26////////////////////////////////////////////////////////////////////////////////////
27// Error.cpp
28
29// #include "stdafx.h"
30// The Error functions and classes are used to catch and/or
31// record database exceptions that occur during run-time. This
32// implementation can be used with or without C++ built-in exception
33// handling. If C++ exception handling is not enabled with the
34// __CPP_EXCEPTIONS__ macro, then the vbDatabaseError enumerated
35// constants can be used to record database errors.
36#include "IErrors.h"
37
38// NOTE: This array must contain the same number of exceptions as the
39// IsisError enumeration.
40const int MaxExceptionMessages = 57;
41const char* isisExceptionMessages[MaxExceptionMessages] = {
42 "Database exception: No exception reported", // None
43 "Database exception: Invalid error code reported", // Invalid
44 "Database exception: Memory exhausted",
45 "Database exception: Error opening xrf file",
46 "Database exception: Error creating xrf file",
47 "Database exception: Error reading xrf file",
48 "Database exception: Error writing xrf file",
49 "Database exception: xrf file is corrupted",
50 "Database exception: xrf file, invalid block",
51 "Database exception: xrf file, invalid status",
52 "Database exception: Error creating an existing mf file",
53 "Database exception: Error opening mf file",
54 "Database exception: Error opening mf file",
55 "Database exception: Error creating mf file",
56 "Database exception: Error reading mf file",
57 "Database exception: Error writing mf file",
58 "Database exception: Access Violation", // AccessViolation
59 "Database exception: Assertion failed", // AssertError
60 "Database exception: Wrong object type", // BadClassID
61 "Database exception: Bad object address", // BadObjectAddress
62 "Database exception: Bad reference", // BadReference
63 "Database exception: Cache full", // CacheFull
64 "Database exception: Checksum error", // ChecksumError
65 "Database exception: Divide by zero error", // DivideByZero
66 "Database exception: Unexpected end of file was reached", // EOFError
67 "Database exception: Error closing file", // FileCloseError
68 "Database exception: File is corrupt", // FileCorrupt
69 "Database exception: Error creating file", // CreationError
70 "Database exception: File already exists", // FileExists
71 "Database exception: Trying to use a closed file", // FileNotOpenError
72 "Database exception: File not ready for reading/writing", // FileNotReady
73 "Database exception: Could not write to file", // NotWriteable
74 "Database exception: Error opening file", // FileOpenError
75 "Database exception: Cannot obtain a file position", // FilePostionError
76 "Database exception: Error reading from file", // FileReadError
77 "Database exception: Error seeking in file", // FileSeekError
78 "Database exception: Error writing to file", // FileWriteError
79 "Database exception: No database open", // NoDatabaseOpen
80 "Database exception: No such file exists", // NoFileExists
81 "Database exception: No objects exist", // NoObjectsExist
82 "Database exception: Accessing a null pointer", // NullPtr
83 "Database exception: Object already exists", // ObjectExists
84 "Database exception: Another object is referencing this file", // Referenced
85 "Database exception: Math overflow error", // OverFlow
86 "Database exception: Parse error", // ParseError
87 "Database exception: Invalid path", // PathError
88 "Database exception: Trying to write to a read-only file", // ReadOnlyFile
89 "Database exception: Stack empty", // StackEmpty
90 "Database exception: Stack full", // StackFull
91 "Database exception: Synchronization Error", // SyncError
92 "Database exception: Math under-flow error", // UnderFlow
93 "Database exception: Wrong file type", // WrongFileType
94
95 // Persistent lock error messages
96 "Database exception: Invalid lock type specified", // LOCK_TYPE
97 "Database exception: Cannot access the file lock header", // FLK_ACCESS
98 "Database exception: Cannot lock the file", // FLK_ERROR
99 "Database exception: Cannot access the record lock header", // RLK_ACCESS
100 "Database exception: Cannot lock the specified record" // RLK_ERROR
101};
102
103const char *isisExceptionMessage(IsisError err)
104// Standalone function that returns a null terminated string that can
105// be use to log or print a database exception message.
106{
107 int error = (int)err;
108 if(error > MaxExceptionMessages) error = ISIS_INVALID_CODE;
109
110 // Find the corresponding message in the exception array
111 return isisExceptionMessages[error];
112}
113
Note: See TracBrowser for help on using the repository browser.