Skip to content

Commit

Permalink
Add documentation to NetworkError
Browse files Browse the repository at this point in the history
  • Loading branch information
bilaalrashid committed Jul 8, 2024
1 parent 96f3fd3 commit 9df40b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Sources/BbcNews/Utils/NetworkError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,26 @@

import Foundation

/// An error occurred during a networking operation.
public enum NetworkError: Error, LocalizedError, CustomStringConvertible {
/// No URL was provided to the caller.
case noUrl

/// An invalid URL was provided to the caller.
case invalidUrl(url: String)

/// A corrupt response was returned by the server.
case invalidResponse

/// A non-success HTTP response code was received by the caller.
///
/// This is any response code outside of the 2xx range.
case unsuccessfulStatusCode(code: Int)

/// The server returned a new destination to resolve the requested response from.
case newDestination(link: FDLink)

/// A human-readable description describing the error.
public var description: String {
switch self {
case .noUrl:
Expand All @@ -29,6 +42,7 @@ public enum NetworkError: Error, LocalizedError, CustomStringConvertible {
}
}

/// A localized message describing what error occurred.
public var errorDescription: String? {
switch self {
case .noUrl:
Expand Down

0 comments on commit 9df40b5

Please sign in to comment.