Skip to content

Commit 0218b97

Browse files
committed
Updated Entity.encode()
1 parent ed29839 commit 0218b97

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

Sources/CoreModel/Entity.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public protocol Entity: Identifiable where Self.ID: CustomStringConvertible, Cod
2121

2222
init(from model: ModelData) throws
2323

24-
func encode() -> ModelData
24+
func encode() throws -> ModelData
2525
}
2626

2727
public extension Model {

Sources/CoreModel/Store.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public extension ModelStorage {
120120

121121
/// Create or edit a managed object.
122122
func insert<T>(_ value: T) async throws where T: Entity, T: Encodable {
123-
let model = value.encode()
123+
let model = try value.encode() // should never fail
124124
try await insert(model)
125125
}
126126

0 commit comments

Comments
 (0)