From 840fa3b5da8de437d756ed55c8fc575188f162c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 12 Mar 2023 18:14:38 +0100 Subject: [PATCH] RecordError DocC --- GRDB/Record/TableRecord.swift | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/GRDB/Record/TableRecord.swift b/GRDB/Record/TableRecord.swift index 58f33e0e0..4e8d8b1b4 100644 --- a/GRDB/Record/TableRecord.swift +++ b/GRDB/Record/TableRecord.swift @@ -669,6 +669,31 @@ extension TableRecord { // MARK: - RecordError /// A record error. +/// +/// `RecordError` is thrown by ``MutablePersistableRecord`` types when an +/// `update` method could not find any row to update: +/// +/// ```swift +/// do { +/// try player.update(db) +/// } catch let RecordError.recordNotFound(databaseTableName: table, key: key) { +/// print("Key \(key) was not found in table \(table).") +/// } +/// ``` +/// +/// `RecordError` is also thrown by ``FetchableRecord`` types when a +/// `find` method does not find any record: +/// +/// ```swift +/// do { +/// let player = try Player.find(db, id: 42) +/// } catch let RecordError.recordNotFound(databaseTableName: table, key: key) { +/// print("Key \(key) was not found in table \(table).") +/// } +/// ``` +/// +/// You can create `RecordError` instances with the +/// ``TableRecord/recordNotFound(_:id:)`` method and its variants. public enum RecordError: Error { /// A record does not exist in the database. ///