File tree Expand file tree Collapse file tree 1 file changed +17
-7
lines changed
Sources/openai-async-image-swiftui Expand file tree Collapse file tree 1 file changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -193,20 +193,30 @@ public extension OpenAIAsyncImage where T == OpenAIDefaultLoader{
193193
194194// MARK: - File private functions -
195195
196+ /// A function that builds the appropriate view for a given `ImageState`.
197+ /// - Parameter state: The current state of the image.
198+ /// - Returns: A SwiftUI view representing the current state of the image.
196199@ViewBuilder
197- fileprivate func imageTpl( _ state : ImageState ) -> some View {
198- switch state{
199- case . loaded( let image) : image. resizable ( )
200- case . loadError( let error) : Text ( error. localizedDescription)
201- case . loading : ProgressView ( )
200+ fileprivate func imageTpl( _ state: ImageState ) -> some View {
201+ switch state {
202+ case . loaded( let image) :
203+ image. resizable ( )
204+ case . loadError( let error) :
205+ Text ( error. localizedDescription)
206+ case . loading:
207+ ProgressView ( )
202208 }
203209}
204210
211+ /// Maps an error to a corresponding `AsyncImageErrors` type.
212+ /// - Parameter error: The error to map, which may be `nil`.
213+ /// - Returns: An `AsyncImageErrors` value if the error can be mapped; otherwise, `nil`.
205214@Sendable
206- fileprivate func errorMapper( _ error : Error ? ) -> AsyncImageErrors ? {
207- if error is CancellationError {
215+ fileprivate func errorMapper( _ error: Error ? ) -> AsyncImageErrors ? {
216+ if error is CancellationError {
208217 return . cancellationError
209218 }
210219
220+ // Return nil for other errors
211221 return nil
212222}
You can’t perform that action at this time.
0 commit comments