Skip to content

Commit dc5f5d9

Browse files
authored
CXXCBC-695: Always return unwrapped doc_exists from txns insert (#771)
1 parent f6886c9 commit dc5f5d9

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

core/transactions/attempt_context_impl.cxx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,7 @@ attempt_context_impl::insert(const core::document_id& id,
12961296
self, "found existing insert or replace of {} while inserting", id);
12971297
return self->op_completed_with_error(
12981298
std::move(cb),
1299-
transaction_operation_failed(FAIL_DOC_ALREADY_EXISTS,
1300-
"found existing insert or replace of same document"));
1299+
document_exists("found existing insert or replace of same document"));
13011300
}
13021301
if (self->check_expiry_pre_commit(STAGE_INSERT, id.key())) {
13031302
return self->op_completed_with_error(
@@ -3708,9 +3707,7 @@ attempt_context_impl::create_staged_insert_error_handler(const core::document_id
37083707
if (doc->links().op() && *doc->links().op() != "insert") {
37093708
return self->op_completed_with_error(
37103709
std::forward<Handler>(cb),
3711-
transaction_operation_failed(FAIL_DOC_ALREADY_EXISTS,
3712-
"doc exists, not a staged insert")
3713-
.cause(DOCUMENT_EXISTS_EXCEPTION));
3710+
document_exists("doc exists, not a staged insert"));
37143711
}
37153712
self->check_and_handle_blocking_transactions(
37163713
*doc,

core/transactions/exceptions.hxx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ public:
223223
: op_exception(std::move(ctx), DOCUMENT_EXISTS_EXCEPTION)
224224
{
225225
}
226+
227+
explicit document_exists(transaction_op_error_context ctx, const std::string& what)
228+
: op_exception(std::move(ctx), what, DOCUMENT_EXISTS_EXCEPTION)
229+
{
230+
}
231+
232+
explicit document_exists(const std::string& what)
233+
: op_exception({ errc::transaction_op::document_exists }, what, DOCUMENT_EXISTS_EXCEPTION)
234+
{
235+
}
226236
};
227237

228238
class query_attempt_not_found : public op_exception

0 commit comments

Comments
 (0)