Skip to content

Commit

Permalink
Merge pull request #12 from MFB-Technologies-Inc/feature/improve-erro…
Browse files Browse the repository at this point in the history
…r-description

Breakout sub-error localizedDescriptions through NetworkService.Failu…
  • Loading branch information
roanutil authored Jul 5, 2023
2 parents 1949153 + 847ed82 commit 4950e88
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/NetworkService/NetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ public final class NetworkService {
case httpResponse(HTTPURLResponse)
case urlError(URLError)
case unknown(NSError)

public var localizedDescription: String {
switch self {
case let .urlResponse(urlResponse):
return urlResponse.description
case let .httpResponse(httpResponse):
return httpResponse.description
case let .urlError(urlError):
return urlError.localizedDescription
case let .unknown(nsError):
return nsError.localizedDescription
}
}
}

public init() {}
Expand Down

0 comments on commit 4950e88

Please sign in to comment.