@@ -361,12 +361,13 @@ public final class RegistryClient: Cancellable {
361
361
}
362
362
363
363
SignatureValidation . extractSigningEntity (
364
- signature: [ UInt8] ( signatureData) ,
365
- signatureFormat: signatureFormat,
366
- configuration: configuration,
367
- fileSystem: fileSystem,
368
- completion: wrappedCompletion
369
- ) }
364
+ signature: [ UInt8] ( signatureData) ,
365
+ signatureFormat: signatureFormat,
366
+ configuration: configuration,
367
+ fileSystem: fileSystem,
368
+ completion: wrappedCompletion
369
+ )
370
+ }
370
371
}
371
372
)
372
373
} ,
@@ -1534,25 +1535,26 @@ public final class RegistryClient: Cancellable {
1534
1535
let start = DispatchTime . now ( )
1535
1536
observabilityScope. emit ( info: " checking availability of \( registry. url) using \( request. url) " )
1536
1537
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
1537
- completion (
1538
- result. tryMap { response in
1539
- observabilityScope
1540
- . emit (
1541
- debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
1542
- )
1543
- switch response. statusCode {
1544
- case 200 :
1545
- return . available
1546
- case let value where AvailabilityStatus . unavailableStatusCodes. contains ( value) :
1547
- return . unavailable
1548
- default :
1549
- if let error = try ? response. parseError ( decoder: self . jsonDecoder) {
1550
- return . error( error. detail)
1551
- }
1552
- return . error( " unknown server error ( \( response. statusCode) ) " )
1538
+ switch result {
1539
+ case . success( let response) :
1540
+ observabilityScope
1541
+ . emit (
1542
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
1543
+ )
1544
+ switch response. statusCode {
1545
+ case 200 :
1546
+ return completion ( . success( . available) )
1547
+ case let value where AvailabilityStatus . unavailableStatusCodes. contains ( value) :
1548
+ return completion ( . success( . unavailable) )
1549
+ default :
1550
+ if let error = try ? response. parseError ( decoder: self . jsonDecoder) {
1551
+ return completion ( . success( . error( error. detail) ) )
1553
1552
}
1553
+ return completion ( . success( . error( " unknown server error ( \( response. statusCode) ) " ) ) )
1554
1554
}
1555
- )
1555
+ case . failure( let error) :
1556
+ return completion ( . failure( RegistryError . availabilityCheckFailed ( registry: registry, error: error) ) )
1557
+ }
1556
1558
}
1557
1559
}
1558
1560
@@ -1671,6 +1673,7 @@ public enum RegistryError: Error, CustomStringConvertible {
1671
1673
case unauthorized
1672
1674
case authenticationMethodNotSupported
1673
1675
case forbidden
1676
+ case availabilityCheckFailed( registry: Registry , error: Error )
1674
1677
case registryNotAvailable( Registry )
1675
1678
case packageNotFound
1676
1679
case packageVersionNotFound
@@ -1770,6 +1773,8 @@ public enum RegistryError: Error, CustomStringConvertible {
1770
1773
return " authentication method not supported "
1771
1774
case . forbidden:
1772
1775
return " forbidden "
1776
+ case . availabilityCheckFailed( let registry, let error) :
1777
+ return " failed checking availability of registry at ' \( registry. url) ': \( error. interpolationDescription) "
1773
1778
case . registryNotAvailable( let registry) :
1774
1779
return " registry at ' \( registry. url) ' is not available at this time, please try again later "
1775
1780
case . packageNotFound:
@@ -1870,7 +1875,13 @@ extension RegistryClient {
1870
1875
public let signing : Signing ?
1871
1876
public let signingEntity : SigningEntity ?
1872
1877
1873
- public init ( name: String , type: String , checksum: String ? , signing: Signing ? , signingEntity: SigningEntity ? ) {
1878
+ public init (
1879
+ name: String ,
1880
+ type: String ,
1881
+ checksum: String ? ,
1882
+ signing: Signing ? ,
1883
+ signingEntity: SigningEntity ?
1884
+ ) {
1874
1885
self . name = name
1875
1886
self . type = type
1876
1887
self . checksum = checksum
0 commit comments