Class: Google::Cloud::Spanner::Rollback

Inherits:
Error
  • Object
show all
Defined in:
lib/google/cloud/spanner/errors.rb

Overview

Rollback

Used to rollback a transaction without passing on the exception. See Client#transaction.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new
db = spanner.client "my-instance", "my-database"

db.transaction do |tx|
  tx.update "users", [{ id: 1, name: "Charlie", active: false }]
  tx.insert "users", [{ id: 2, name: "Harvey",  active: true }]

  if something_wrong?
    # Rollback the transaction without passing on the error
    # outside of the transaction method.
    raise Google::Cloud::Spanner::Rollback
  end
end