Exception: Mongo::Error::InvalidTransactionOperation

Inherits:
Mongo::Error
  • Object
show all
Defined in:
build/ruby-driver-v2.19/lib/mongo/error/invalid_transaction_operation.rb

Overview

Exception raised if an invalid operation is attempted as part of a transaction.

Since:

  • 2.6.0

Constant Summary collapse

NO_TRANSACTION_STARTED =

The error message for when a user attempts to commit or abort a transaction when none is in progress.

Since:

  • 2.6.0

'no transaction started'.freeze
TRANSACTION_ALREADY_IN_PROGRESS =

The error message for when a user attempts to start a transaction when one is already in progress.

Since:

  • 2.6.0.

'transaction already in progress'.freeze
INVALID_READ_PREFERENCE =

The error message for when a transaction read operation uses a non-primary read preference.

Since:

  • 2.6.0

'read preference in a transaction must be primary'.freeze
UNACKNOWLEDGED_WRITE_CONCERN =

The error message for when a transaction is started with an unacknowledged write concern.

Since:

  • 2.6.0

'transactions do not support unacknowledged write concern'.freeze

Constants inherited from Mongo::Error

BAD_VALUE, CODE, CURSOR_NOT_FOUND, ERR, ERRMSG, ERROR, TRANSIENT_TRANSACTION_ERROR_LABEL, UNKNOWN_ERROR, UNKNOWN_TRANSACTION_COMMIT_RESULT_LABEL, WRITE_CONCERN_ERROR, WRITE_CONCERN_ERRORS, WRITE_ERRORS

Instance Attribute Summary

Attributes included from Notable

#connection_global_id, #generation, #service_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mongo::Error

#change_stream_resumable?, #write_concern_error_label?, #write_concern_error_labels

Methods included from ChangeStreamResumable

#change_stream_resumable?

Methods included from WriteRetryable

#write_retryable?

Methods included from Labelable

#add_label, #label?, #labels

Methods included from Notable

#add_note, #add_notes, #notes, #to_s

Constructor Details

#initialize(msg) ⇒ InvalidTransactionOperation

Instantiate the new exception.

Examples:

Instantiate the exception.

Mongo::Error::InvalidTransactionOperation.new(msg)

Since:

  • 2.6.0



54
55
56
# File 'build/ruby-driver-v2.19/lib/mongo/error/invalid_transaction_operation.rb', line 54

def initialize(msg)
  super(msg)
end

Class Method Details

.cannot_call_after_msg(last_op, current_op) ⇒ Object

Create an error message for incorrectly running a transaction operation that cannot be run after the previous one.

Examples:

Create the error message.

InvalidTransactionOperation.cannot_call_after(last_op, current_op)

Parameters:

  • last_op (Symbol)

    The operation which was run before.

  • current_op (Symbol)

    The operation which cannot be run.

Since:

  • 2.6.0



80
81
82
# File 'build/ruby-driver-v2.19/lib/mongo/error/invalid_transaction_operation.rb', line 80

def self.cannot_call_after_msg(last_op, current_op)
  "Cannot call #{current_op} after calling #{last_op}"
end

.cannot_call_twice_msg(op) ⇒ Object

Create an error message for incorrectly running a transaction operation twice.

Examples:

Create the error message.

InvalidTransactionOperation.cannot_call_twice(op)

Parameters:

  • op (Symbol)

    The operation which was run twice.

Since:

  • 2.6.0



66
67
68
# File 'build/ruby-driver-v2.19/lib/mongo/error/invalid_transaction_operation.rb', line 66

def self.cannot_call_twice_msg(op)
  "cannot call #{op} twice"
end