Exception: Sqlx::RecordNotUnique

Inherits:
StandardError
  • Object
show all
Defined in:
runtime/sqlx/errors.rb,
runtime/sqlx/errors.rbs

Overview

Raised when an INSERT/UPDATE trips a unique index. Apps rescue it to turn a lost race into a redirect rather than a 500.

Raised by each Sqlx::Database, not from here: the driver error surfaces in Sqlx::Database.exec, the only place holding it. The sqlite adapter (database/sqlite.rb) maps it in exec, keyed on the engine's own message text ("UNIQUE constraint failed:

."); the PostgreSQL adapter maps its SQLSTATE.

Instance Method Summary collapse

Constructor Details

#initialize(message = "Sqlx::RecordNotUnique") ⇒ RecordNotUnique

Returns a new instance of RecordNotUnique.

Parameters:

  • message (String) (defaults to: "Sqlx::RecordNotUnique")


11
# File 'runtime/sqlx/errors.rbs', line 11

def initialize: (?String message) -> void