OxL Справочник OxL
РусскийEnglish

data DbError

A database operation failed: Conflict (duplicate key, violated unique index), NotFound (update or delete of a missing row), Busy (locked by another connection, or a builtin shard transaction to retry after a leader change), Other, CrossShardTx (an atomic/transaction touched rows of two shards of builtin://; 2PC is 1.0, D-4387).

Example:

oxl✓ проверяется в CI
use std.orm { Db }

@table("notes")
data Note {
  @pk id: i64
  text: str
}

fn main() io, db {
  let db = Db.open("sqlite::memory:")!
  db.insert(Note{ id: 1, text: "a" })
  match db.tryInsert(Note{ id: 1, text: "b" }) {
    DbError e => print("{e.kind == DbErrorKind.Conflict}")
    _ => print("inserted twice?")
  }
}
Вывод
true
@error pub(api) data DbError

С версии. 1.0.0-beta

Поля

pub(api) kind: DbErrorKind

What went wrong.

pub(api) msg: str

Detail text of the database.

Определено в: std/core/types.oxl:318

См. также