mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-30 22:59:35 +02:00
Improved error handling
This commit is contained in:
parent
01678f2c91
commit
8c87b31e56
14 changed files with 220 additions and 141 deletions
|
@ -9,15 +9,15 @@ import Foundation
|
|||
import RealmSwift
|
||||
|
||||
extension Object {
|
||||
func save() {
|
||||
let realm = try! Realm()
|
||||
try! realm.write {
|
||||
func save() throws {
|
||||
let realm = try Realm()
|
||||
try realm.write {
|
||||
realm.add(self, update: .modified)
|
||||
}
|
||||
}
|
||||
|
||||
func update(handler: () -> Void) {
|
||||
try! self.realm?.write {
|
||||
func update(handler: () -> Void) throws {
|
||||
try self.realm?.write {
|
||||
handler()
|
||||
}
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ extension EmbeddedObject {
|
|||
}
|
||||
|
||||
protocol Deletable {
|
||||
func delete()
|
||||
func delete() throws
|
||||
}
|
||||
|
||||
extension Deletable where Self: Object {
|
||||
func delete() {
|
||||
try! self.realm?.write {
|
||||
func delete() throws {
|
||||
try self.realm?.write {
|
||||
self.realm?.delete(self)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue