1dnl $Id: m4.err,v 10.146 2007/10/24 16:06:07 bostic Exp $ 2dnl 3dnl ################################################################### 4dnl m4_err_mem_insufficient -- 5dnl Inline error for insufficient memory to return a key/data pair. 6dnl ################################################################### 7define(m4_err_mem_insufficient, [dnl 8ifelse(M4EXCEPT, except_only, 9[and a m4_ref(DbMemoryException) is thrown], 10[and the error DB_BUFFER_SMALL is returned])]) 11dnl ################################################################### 12dnl General errors: 13dnl 14dnl There are 3 cases: the C API, which just returns errors, the C++ API 15dnl which either throws exceptions or returns errors, and the XML API which 16dnl just throws exceptions. 17dnl 18dnl #1: API name 19dnl #2: Variadic list of errors. 20dnl 21dnl Some errors are well-known, and can either throw an exception or be 22dnl a normal return: buffersmall, deadlock, filenotfound, memory. In this 23dnl case, we immediately output the error for C, and save up the output for 24dnl C++, because we list exceptions after the laundry list of error returns. 25dnl 26dnl If the error isn't well-known, it's expected to be in pairs: the error 27dnl followed by the string associated with it. 28dnl ################################################################### 29define(m4_err, [dnl 30define([__m4_errapi], [m4_refT($1)]) 31define([__m4_errneedheader], yes) 32m4_header(Errors) 33__m4_errloop(shift($@)) 34undivert(1)]) 35define(m4_errstr, [dnl 36define([__m4_errapi], [$1]) 37define([__m4_errneedheader], yes) 38m4_header(Errors) 39__m4_errloop(shift($@)) 40undivert(1)]) 41dnl 42dnl ################################################################### 43dnl __m4_errheader 44dnl If we need header text, output it, but only once. 45dnl ################################################################### 46define(__m4_errheader, [ifelse(__m4_errneedheader, yes, [m4_p([dnl 47The __m4_errapi 48ifelse(M4EXCEPT, except_return, 49[may fail and throw 50ifelse(M4PRODUCT, XML, m4_ref(XmlException)[,], m4_ref(DbException)[,]) 51encapsulating one of the following non-zero errors, or return one of 52the following non-zero errors:], 53M4EXCEPT, except_only, 54[may fail and throw 55ifelse(M4PRODUCT, XML, m4_ref(XmlException)[,], m4_ref(DbException)[,]) 56encapsulating one of the following non-zero errors:], 57[may fail and return one of the following non-zero errors:])]) 58define([__m4_errneedheader], no)])]) 59dnl 60dnl ################################################################### 61dnl __m4_errloop 62dnl Helper macro: loop through exception list. 63dnl ################################################################### 64define(__m4_errloop, [dnl 65ifelse([$1],,, 66dnl ################################################################### 67dnl Buffer Small 68dnl Requires subsequent argument which is the reason for the failure. 69dnl ################################################################### 70[$1], buffersmall, [dnl 71ifelse(M4EXCEPT, return_only, [dnl 72__m4_errheader 73m4_tagbegin 74m4_tag(DB_BUFFER_SMALL, [The [$2].]) 75m4_tagend],[dnl 76divert(1) 77m4_p([If the [$2], the __m4_errapi will fail and 78ifelse(M4EXCEPT, except_return, [either return DB_BUFFER_SMALL or]) 79throw a m4_ref(DbMemoryException) exception.]) 80divert(0)]) 81__m4_errloop(shift(shift($@)))], 82dnl ################################################################### 83dnl Deadlock. 84dnl ################################################################### 85[$1], deadlock, [dnl 86ifelse(M4EXCEPT, return_only, [dnl 87__m4_errheader 88m4_tagbegin 89m4_tag(DB_LOCK_DEADLOCK, [dnl 90A transactional database environment operation was selected to resolve 91a deadlock.]) 92m4_tag(DB_LOCK_NOTGRANTED, [dnl 93A m4_cam database environment configured for lock timeouts was unable 94to grant a lock in the allowed time.]) 95m4_tagend],[dnl 96divert(1) 97m4_p([If a transactional database environment operation was selected to 98resolve a deadlock, the __m4_errapi will fail and 99ifelse(M4EXCEPT, except_return, [either return m4_ref(DB_LOCK_DEADLOCK) or]) 100throw a m4_ref(DbDeadlockException) exception.]) 101m4_p([If a m4_cam database environment configured for lock timeouts was unable 102to grant a lock in the allowed time, the __m4_errapi will fail and 103ifelse(M4EXCEPT, except_return, [either return m4_ref(DB_LOCK_NOTGRANTED) or]) 104throw a m4_ref(DbLockNotGrantedException) exception.]) 105divert(0)]) 106__m4_errloop(shift($@))], 107dnl ################################################################### 108dnl Filenotfound 109dnl ################################################################### 110[$1], filenotfound, [dnl 111m4_tagbegin 112m4_tag(ENOENT, [The file or directory does not exist.]) 113m4_tagend 114__m4_errloop(shift($@))], 115dnl ################################################################### 116dnl LockNotGranted 117dnl ################################################################### 118[$1], locknotgranted, [dnl 119ifelse(M4EXCEPT, return_only, [dnl 120__m4_errheader 121m4_tagbegin 122m4_tag(DB_LOCK_NOTGRANTED, [dnl 123The $2 lock could not be granted before the wait-time expired.]) 124m4_tagend],[dnl 125divert(1) 126m4_p([If the $2 lock could not be granted before the wait-time expired, 127the __m4_errapi will fail and 128ifelse(M4EXCEPT, except_return, [either return DB_LOCK_NOTGRANTED or]) 129throw a m4_ref(DbLockNotGrantedException) exception.]) 130divert(0)]) 131__m4_errloop(shift(shift($@)))], 132dnl ################################################################### 133dnl Memory 134dnl Requires subsequent argument which is the reason for the failure. 135dnl ################################################################### 136[$1], memory, [dnl 137ifelse(M4EXCEPT, return_only, [dnl 138__m4_errheader 139m4_tagbegin 140m4_tag(ENOMEM, [The [$2].]) 141m4_tagend],[dnl 142divert(1) 143m4_p([If the [$2], the __m4_errapi will fail and 144ifelse(M4EXCEPT, except_return, [either return ENOMEM or]) 145throw a DbMemoryException.]) 146divert(0)]) 147__m4_errloop(shift(shift($@)))], 148dnl ################################################################### 149dnl XML: generic underlying error from the core DB. 150dnl ################################################################### 151[$1], dberr, [dnl 152__m4_errheader 153m4_tagbegin 154m4_tag(DATABASE_ERROR, [dnl 155An error occurred in an underlying m4_db database. The 156m4_refT(xmlexception_getdberror) will return the error code for the 157error.]) 158m4_tagend 159__m4_errloop(shift($@))], 160dnl ################################################################### 161dnl EACCESS because the database is read-only. 162dnl ################################################################### 163[$1], readonly, [dnl 164__m4_errheader 165m4_tagbegin 166m4_tag(EACCES, [An attempt was made to modify a read-only database.]) 167m4_tagend 168__m4_errloop(shift($@))], 169dnl ################################################################### 170dnl EAGAIN because the region is unavailable. 171dnl ################################################################### 172[$1], regionagain, [dnl 173__m4_errheader 174m4_tagbegin 175m4_tag(EAGAIN, [dnl 176The shared memory region was locked and (repeatedly) unavailable.]) 177m4_tagend 178__m4_errloop(shift($@))], 179dnl ################################################################### 180dnl EINVAL 181dnl Requires subsequent argument which is empty or a list of may be 182dnl additional reasons. 183dnl ################################################################### 184[$1], einval, [dnl 185__m4_errheader 186m4_tagbegin 187m4_tag(EINVAL, [dnl 188ifelse([$2],, An, If [$2]; or if an) 189invalid flag value or parameter was specified.]) 190m4_tagend 191__m4_errloop(shift(shift($@)))], 192dnl ################################################################### 193dnl DB_REP_HANDLE_DEAD -- replication rolled back a commit record. 194dnl ################################################################### 195[$1], rephandle, [dnl 196__m4_errheader 197m4_tagbegin 198m4_tag(DB_REP_HANDLE_DEAD, [dnl 199The database handle has been invalidated because a replication election 200unrolled a committed transaction.]) 201m4_tagend 202__m4_errloop(shift($@))], 203dnl ################################################################### 204dnl DB_REP_LOCKOUT -- replication blocked by client/master sync-up. 205dnl ################################################################### 206[$1], replockout, [dnl 207__m4_errheader 208m4_tagbegin 209m4_tag(DB_REP_LOCKOUT, [dnl 210The operation was blocked by client/master synchronization.]) 211m4_tagend 212__m4_errloop(shift($@))], 213dnl ################################################################### 214dnl DB_REP_LEASE_EXPIRED -- replication lease expired 215dnl ################################################################### 216[$1], replease, [dnl 217__m4_errheader 218m4_tagbegin 219m4_tag(DB_REP_LEASE_EXPIRED, [dnl 220The operation failed because the site's replication master lease has expired.]) 221m4_tagend 222__m4_errloop(shift($@))], 223dnl ################################################################### 224dnl EPERM because write operation with read-only CDB cursor. 225dnl ################################################################### 226[$1], cdbperm, [dnl 227__m4_errheader 228m4_tagbegin 229m4_tag(EPERM , [dnl 230Write attempted on read-only cursor when the m4_ref(DB_INIT_CDB) flag was 231specified to m4_ref(dbenv_open).]) 232m4_tagend 233__m4_errloop(shift($@))], 234dnl ################################################################### 235dnl Bad secondary. 236dnl ################################################################### 237[$1], secondary_bad, [dnl 238__m4_errheader 239m4_tagbegin 240m4_tag(DB_SECONDARY_BAD, [dnl 241A secondary index references a nonexistent primary key.]) 242m4_tagend 243__m4_errloop(shift($@))], 244dnl ################################################################### 245dnl Empty entry (to support ifelse() constructs). 246dnl ################################################################### 247[$1], empty, [__m4_errloop(shift($@))], 248dnl ################################################################### 249dnl Everything else. 250dnl ################################################################### 251[dnl 252__m4_errheader 253m4_tagbegin 254m4_tag([$1], [$2]) 255m4_tagend 256__m4_errloop(shift(shift($@)))])]) 257