Add & use MASError.unknownAppID(AppID).

Partial #533

Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
This commit is contained in:
Ross Goldberg 2024-10-28 14:38:06 -04:00
parent d59249ac33
commit 0a05cd438f
No known key found for this signature in database
3 changed files with 7 additions and 2 deletions

View file

@ -27,7 +27,7 @@ extension MAS {
func run(searcher: AppStoreSearcher) throws { func run(searcher: AppStoreSearcher) throws {
guard let result = try searcher.lookup(appID: appID).wait() else { guard let result = try searcher.lookup(appID: appID).wait() else {
throw MASError.noSearchResultsFound throw MASError.unknownAppID(appID)
} }
guard let url = URL(string: result.trackViewUrl) else { guard let url = URL(string: result.trackViewUrl) else {

View file

@ -28,7 +28,7 @@ extension MAS {
func run(searcher: AppStoreSearcher) throws { func run(searcher: AppStoreSearcher) throws {
do { do {
guard let result = try searcher.lookup(appID: appID).wait() else { guard let result = try searcher.lookup(appID: appID).wait() else {
throw MASError.noSearchResultsFound throw MASError.unknownAppID(appID)
} }
print(AppInfoFormatter.format(app: result)) print(AppInfoFormatter.format(app: result))

View file

@ -27,6 +27,9 @@ enum MASError: Error, Equatable {
case searchFailed case searchFailed
case noSearchResultsFound case noSearchResultsFound
case unknownAppID(AppID)
case noVendorWebsite case noVendorWebsite
case notInstalled(appID: AppID) case notInstalled(appID: AppID)
@ -83,6 +86,8 @@ extension MASError: CustomStringConvertible {
return "Search failed" return "Search failed"
case .noSearchResultsFound: case .noSearchResultsFound:
return "No results found" return "No results found"
case .unknownAppID(let appID):
return "Unknown app ID \(appID)"
case .noVendorWebsite: case .noVendorWebsite:
return "App does not have a vendor website" return "App does not have a vendor website"
case .notInstalled(let appID): case .notInstalled(let appID):