Skip to content

Commit

Permalink
added user facing error description for some cases in YouTubeKitError
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeichhorn committed Nov 9, 2022
1 parent b93db48 commit 7dcbb57
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Sources/YouTubeKit/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public enum YouTubeKitError: Error {
public enum YouTubeKitError: String, Error {
case maxRetriesExceeded
case htmlParseError
case extractError
Expand All @@ -20,3 +20,28 @@ public enum YouTubeKitError: Error {
case membersOnly
case videoRegionBlocked
}

extension YouTubeKitError: LocalizedError {

public var errorDescription: String? {
switch self {
case .videoUnavailable:
return NSLocalizedString("Video unavailable", comment: "")

case .videoAgeRestricted:
return NSLocalizedString("Video age restricted", comment: "")

case .liveStreamError:
return NSLocalizedString("Can't extract video from livestream", comment: "")

case .videoPrivate:
return NSLocalizedString("Video is private", comment: "")

case .membersOnly:
return NSLocalizedString("Video is members only", comment: "")

default: return nil
}
}

}

0 comments on commit 7dcbb57

Please sign in to comment.