Skip to content

Commit 52b4e17

Browse files
committed
Update error messages in ModelOutput.value(...) methods
# Conflicts: # FirebaseAI/Sources/Types/Public/Generable/ModelOutput.swift
1 parent e0febca commit 52b4e17

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

FirebaseAI/Sources/Types/Public/Generable/ModelOutput.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,20 @@ public struct ModelOutput: Sendable, Generable, CustomDebugStringConvertible {
158158
forProperty property: String) throws -> Value
159159
where Value: ConvertibleFromModelOutput {
160160
guard case let .structure(properties, _) = kind else {
161-
throw DecodingError.notAStructure
161+
throw GenerativeModel.GenerationError.decodingFailure(
162+
GenerativeModel.GenerationError.Context(debugDescription: """
163+
\(Self.self) does not contain an object.
164+
Content: \(self.kind)
165+
""")
166+
)
162167
}
163168
guard let value = properties[property] else {
164-
throw DecodingError.missingProperty(name: property)
169+
throw GenerativeModel.GenerationError.decodingFailure(
170+
GenerativeModel.GenerationError.Context(debugDescription: """
171+
\(Self.self) does not contain a property '\(property)'.
172+
Content: \(self)
173+
""")
174+
)
165175
}
166176

167177
return try Value(value)

0 commit comments

Comments
 (0)