Skip to content

Commit

Permalink
Update ConnectError.unpackedDetails documentation comment (#324)
Browse files Browse the repository at this point in the history
Updates the documentation comment for `ConnectError.unpackedDetails` to
include suggested syntax for accessing the first error of a specific
type in a manner that is compatible with Swift 6 and Xcode 16.x.

For more information, please refer to #323.

Closes #323

Signed-off-by: Eddie Seay <[email protected]>
  • Loading branch information
eseay authored Nov 26, 2024
1 parent 8d5d416 commit d7ec67a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Libraries/Connect/Public/Interfaces/ConnectError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ public struct ConnectError: Swift.Error, Sendable {
/// Any decoding errors are ignored, and the detail will simply be omitted from the list.
///
/// To access only the first error of a specific type:
/// `let unpackedError: MyError? = error.unpackedDetails().first`
///
/// ```
/// let unpackedErrors: [MyError] = error.unpackedDetails()
/// let unpackedError = unpackedErrors.first
/// // OR
/// let unpackedError = (error.unpackedDetails() as [MyError]).first
/// ```
///
/// When calling this function from Swift 5, the compiler will allow the following
/// alternative syntax:
///
/// ```
/// let unpackedError: MyError? = error.unpackedDetails().first
/// ```
///
/// - returns: The matching unpacked typed error details.
public func unpackedDetails<Output: ProtobufMessage>() -> [Output] {
Expand Down

0 comments on commit d7ec67a

Please sign in to comment.