diff options
author | Michael Cahill <mjc@wiredtiger.com> | 2014-12-04 09:19:46 +1100 |
---|---|---|
committer | Michael Cahill <mjc@wiredtiger.com> | 2014-12-04 09:19:46 +1100 |
commit | 4ad452d526163080bfc85b0158b4fb7cf9e9a3ec (patch) | |
tree | 2c52bcea4a2e42a708f67e8319d27796e6059aa3 /dist/api_err.py | |
parent | caa5e82926639fca349ea70d0f7b17e939d03ad7 (diff) | |
parent | 46fa7f0b6397fe765c5e8c2853f9cd0b067bc808 (diff) | |
download | mongo-4ad452d526163080bfc85b0158b4fb7cf9e9a3ec.tar.gz |
Merge pull request #1430 from wiredtiger/revert-error-value-change
Revert error return value changes.
Diffstat (limited to 'dist/api_err.py')
-rw-r--r-- | dist/api_err.py | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/dist/api_err.py b/dist/api_err.py index 352bfd5ca94..4892e920278 100644 --- a/dist/api_err.py +++ b/dist/api_err.py @@ -2,10 +2,51 @@ # message code in strerror.c. import re, textwrap - -import api_data from dist import compare_srcfile +class Error: + def __init__(self, name, value, desc, long_desc=None, **flags): + self.name = name + self.value = value + self.desc = desc + self.long_desc = long_desc + self.flags = flags + +# We don't want our error returns to conflict with any other package, +# so use an uncommon range, specifically, -31,800 to -31,999. +# +# These numbers cannot change without breaking backward compatibility, +# and are listed in error value order. +errors = [ + Error('WT_ROLLBACK', -31800, + 'conflict between concurrent operations', ''' + This error is generated when an operation cannot be completed + due to a conflict with concurrent operations. The operation + may be retried; if a transaction is in progress, it should be + rolled back and the operation retried in a new transaction.'''), + Error('WT_DUPLICATE_KEY', -31801, + 'attempt to insert an existing key', ''' + This error is generated when the application attempts to insert + a record with the same key as an existing record without the + 'overwrite' configuration to WT_SESSION::open_cursor.'''), + Error('WT_ERROR', -31802, + 'non-specific WiredTiger error', ''' + This error is returned when an error is not covered by a + specific error return.'''), + Error('WT_NOTFOUND', -31803, + 'item not found', ''' + This error indicates an operation did not find a value to + return. This includes cursor search and other operations + where no record matched the cursor's search key such as + WT_CURSOR::update or WT_CURSOR::remove.'''), + Error('WT_PANIC', -31804, + 'WiredTiger library panic', ''' + This error indicates an underlying problem that requires the + application exit and restart.'''), + Error('WT_RESTART', -31805, + 'restart the operation (internal)', undoc=True), +] + # Update the #defines in the wiredtiger.in file. tmp_file = '__tmp' tfile = open(tmp_file, 'w') @@ -19,12 +60,7 @@ for line in open('../src/include/wiredtiger.in', 'r'): elif line.count('Error return section: BEGIN'): tfile.write(' */\n') skip = 1 - - # We don't want our error returns to conflict with any other - # package, so use an uncommon range, specifically, -31,800 to - # -31,999. - v = -31800 - for err in api_data.errors: + for err in errors: if 'undoc' in err.flags: tfile.write('/*! @cond internal */\n') tfile.write('/*!%s.%s */\n' % @@ -33,8 +69,7 @@ for line in open('../src/include/wiredtiger.in', 'r'): ''.join('\n * ' + l for l in textwrap.wrap( textwrap.dedent(err.long_desc).strip(), 77)) + '\n' if err.long_desc else '')) - tfile.write('#define\t%s\t%d\n' % (err.name, v)) - v -= 1 + tfile.write('#define\t%s\t%d\n' % (err.name, err.value)) if 'undoc' in err.flags: tfile.write('/*! @endcond */\n') tfile.write('/*\n') @@ -64,7 +99,7 @@ wiredtiger_strerror(int error) switch (error) { ''') -for err in api_data.errors: +for err in errors: tfile.write('\tcase ' + err.name + ':\n') tfile.write('\t\treturn ("' + err.name + ': ' + err.desc + '");\n') @@ -101,7 +136,7 @@ for line in open(doc, 'r'): tfile.write('@endif\n\n') skip = 1 - for err in api_data.errors: + for err in errors: if 'undoc' in err.flags: continue tfile.write( |