Skip to content

Commit d320ea2

Browse files
committed
When getting the error context handle the case where the exception does not come from pycbc_core
Motivation ========== If the error context is not set and the exception does not come from pycbc_core, calling an exception's error_context() method results in a "AttributeError: 'NoneType' object has no attribute 'error_context'". Changes ======= In the error_context getter, if the _base attribute of a CouchbaseException is None and _context is None, return an empty error context. Change-Id: I0b37a81d4369dbd920665b95be1eb59d34f20e61 Reviewed-on: https://review.couchbase.org/c/couchbase-python-client/+/203433 Reviewed-by: Jared Casey <jared.casey@couchbase.com> Tested-by: Build Bot <build@couchbase.com>
1 parent a1161ae commit d320ea2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

couchbase/exceptions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,10 @@ def context(self) -> ErrorContextType:
372372
@property
373373
def error_context(self) -> ErrorContextType:
374374
if not self._context:
375-
base_ec = self._base.error_context() or dict()
375+
if self._base:
376+
base_ec = self._base.error_context() or dict()
377+
else:
378+
base_ec = dict()
376379
self._context = ErrorContext.from_dict(**base_ec)
377380
return self._context
378381

0 commit comments

Comments
 (0)