Skip to content

Commit

Permalink
Don't throw unnecessary when closing cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Jan 3, 2024
1 parent 9455907 commit df9ee30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ CursorWrap::~CursorWrap() {
}

Value CursorWrap::close(const CallbackInfo& info) {
if (!this->cursor) {
return throwError(info.Env(), "cursor.close: Attempt to close a closed cursor!");
if (this->cursor) {
mdb_cursor_close(this->cursor);
this->cursor = nullptr;
}
mdb_cursor_close(this->cursor);
this->cursor = nullptr;
return info.Env().Undefined();
}

Expand Down
4 changes: 3 additions & 1 deletion util/RangeIterable.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class RangeIterable {
} else {
iteratorResult = iterator.next();
if (iteratorResult.then) {
if (!async) throw new Error('Can not synchronously iterate with asynchronous values');
if (!async) {
throw new Error('Can not synchronously iterate with asynchronous values');
}
return iteratorResult.then(iteratorResult => this.next(iteratorResult), onError);
}
}
Expand Down

0 comments on commit df9ee30

Please sign in to comment.