2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1997-2002
5
* Sleepycat Software. All rights reserved.
10
#ifndef _CXX_EXCEPT_H_
11
#define _CXX_EXCEPT_H_
13
#include "cxx_common.h"
15
////////////////////////////////////////////////////////////////
16
////////////////////////////////////////////////////////////////
18
// Forward declarations
21
class DbDeadlockException; // forward
22
class DbException; // forward
23
class DbLockNotGrantedException; // forward
24
class DbLock; // forward
25
class DbMemoryException; // forward
26
class DbRunRecoveryException; // forward
29
////////////////////////////////////////////////////////////////
30
////////////////////////////////////////////////////////////////
35
// Almost any error in the DB library throws a DbException.
36
// Every exception should be considered an abnormality
37
// (e.g. bug, misuse of DB, file system error).
39
// NOTE: We would like to inherit from class exception and
40
// let it handle what(), but there are
41
// MSVC++ problems when <exception> is included.
43
class _exported DbException
46
virtual ~DbException();
48
DbException(const char *description);
49
DbException(const char *prefix, int err);
50
DbException(const char *prefix1, const char *prefix2, int err);
51
int get_errno() const;
52
virtual const char *what() const;
54
DbException(const DbException &);
55
DbException &operator = (const DbException &);
63
// A specific sort of exception that occurs when
64
// an operation is aborted to resolve a deadlock.
66
class _exported DbDeadlockException : public DbException
69
virtual ~DbDeadlockException();
70
DbDeadlockException(const char *description);
72
DbDeadlockException(const DbDeadlockException &);
73
DbDeadlockException &operator = (const DbDeadlockException &);
77
// A specific sort of exception that occurs when
78
// a lock is not granted, e.g. by lock_get or lock_vec.
79
// Note that the Dbt is only live as long as the Dbt used
80
// in the offending call.
82
class _exported DbLockNotGrantedException : public DbException
85
virtual ~DbLockNotGrantedException();
86
DbLockNotGrantedException(const char *prefix, db_lockop_t op,
87
db_lockmode_t mode, const Dbt *obj, const DbLock lock, int index);
88
DbLockNotGrantedException(const DbLockNotGrantedException &);
89
DbLockNotGrantedException &operator =
90
(const DbLockNotGrantedException &);
92
db_lockop_t get_op() const;
93
db_lockmode_t get_mode() const;
94
const Dbt* get_obj() const;
95
DbLock *get_lock() const;
96
int get_index() const;
107
// A specific sort of exception that occurs when
108
// user declared memory is insufficient in a Dbt.
110
class _exported DbMemoryException : public DbException
113
virtual ~DbMemoryException();
114
DbMemoryException(Dbt *dbt);
115
DbMemoryException(const char *description);
116
DbMemoryException(const char *prefix, Dbt *dbt);
117
DbMemoryException(const char *prefix1, const char *prefix2, Dbt *dbt);
118
Dbt *get_dbt() const;
120
DbMemoryException(const DbMemoryException &);
121
DbMemoryException &operator = (const DbMemoryException &);
128
// A specific sort of exception that occurs when
129
// recovery is required before continuing DB activity.
131
class _exported DbRunRecoveryException : public DbException
134
virtual ~DbRunRecoveryException();
135
DbRunRecoveryException(const char *description);
137
DbRunRecoveryException(const DbRunRecoveryException &);
138
DbRunRecoveryException &operator = (const DbRunRecoveryException &);
141
#endif /* !_CXX_EXCEPT_H_ */