Skip to content

Commit d62982c

Browse files
seanmiller802Sean Miller
andauthored
Add Type to relationshipWasNil RuneError (#86)
* Add Type to relationshipWasNil RuneError Co-authored-by: Sean Miller <sean@withapollo.com>
1 parent da80749 commit d62982c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Sources/Alchemy/SQL/Rune/Relationships/Relationship.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public protocol RelationshipAllowed {
5252

5353
extension Model {
5454
public static func from(_ value: Self?) throws -> Self {
55-
try value.unwrap(or: RuneError.relationshipWasNil)
55+
try value.unwrap(or: RuneError.relationshipWasNil(type: Self.self))
5656
}
5757
}
5858

Sources/Alchemy/SQL/Rune/RuneError.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ public struct RuneError: Error {
1414
public static let notFound = RuneError("Unable to find an element of this type.")
1515

1616
/// Couldn't unwrap a relationship that was expected to be nonnil.
17-
public static let relationshipWasNil = RuneError("This non-optional relationship had no matching models.")
17+
public static func relationshipWasNil<M: Model>(type: M.Type) -> RuneError {
18+
RuneError("This non-optional relationship to \(type) has no matching models.")
19+
}
1820

1921
/// Couldn't sync a model; its id was nil.
2022
public static let syncErrorNoId = RuneError("Can't .sync() an object with a nil `id`.")

0 commit comments

Comments
 (0)