2019-10-09 09:38:12 +02:00
//
// F e e d l y A c c o u n t D e l e g a t e E r r o r . s w i f t
// A c c o u n t
//
// C r e a t e d b y K i e l G i l l a r d o n 9 / 1 0 / 1 9 .
// C o p y r i g h t © 2 0 1 9 R a n c h e r o S o f t w a r e , L L C . A l l r i g h t s r e s e r v e d .
//
import Foundation
enum FeedlyAccountDelegateError : LocalizedError {
case notLoggedIn
2019-11-25 08:19:33 +01:00
case unexpectedResourceId ( String )
2019-10-09 09:38:12 +02:00
case unableToAddFolder ( String )
case unableToRenameFolder ( String , String )
case unableToRemoveFolder ( String )
2019-11-15 03:11:41 +01:00
case unableToMoveFeedBetweenFolders ( WebFeed , Folder , Folder )
2019-10-09 09:38:12 +02:00
case addFeedChooseFolder
case addFeedInvalidFolder ( Folder )
2019-10-11 11:32:21 +02:00
case unableToRenameFeed ( String , String )
2019-11-15 03:11:41 +01:00
case unableToRemoveFeed ( WebFeed )
2019-10-09 09:38:12 +02:00
var errorDescription : String ? {
switch self {
case . notLoggedIn :
2019-10-22 12:58:05 +02:00
return NSLocalizedString ( " Please add the Feedly account again. " , comment : " Feedly – Credentials not found. " )
2019-10-09 09:38:12 +02:00
2019-11-25 08:19:33 +01:00
case . unexpectedResourceId ( let resourceId ) :
let template = NSLocalizedString ( " Could not encode the identifier “%@”. " , comment : " Feedly – Could not encode resource id to send to Feedly. " )
return String ( format : template , resourceId )
2019-10-09 09:38:12 +02:00
case . unableToAddFolder ( let name ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Could not create a folder named “%@”. " , comment : " Feedly – Could not create a folder/collection. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , name )
case . unableToRenameFolder ( let from , let to ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Could not rename “%@” to “%@”. " , comment : " Feedly – Could not rename a folder/collection. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , from , to )
case . unableToRemoveFolder ( let name ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Could not remove the folder named “%@”. " , comment : " Feedly – Could not remove a folder/collection. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , name )
case . unableToMoveFeedBetweenFolders ( let feed , _ , let to ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Could not move “%@” to “%@”. " , comment : " Feedly – Could not move a feed between folders/collections. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , feed . nameForDisplay , to . nameForDisplay )
case . addFeedChooseFolder :
2019-10-22 12:58:05 +02:00
return NSLocalizedString ( " Please choose a folder to contain the feed. " , comment : " Feedly – Feed can only be added to folders. " )
2019-10-09 09:38:12 +02:00
case . addFeedInvalidFolder ( let invalidFolder ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Feeds cannot be added to the “%@” folder. " , comment : " Feedly – Feed can only be added to folders. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , invalidFolder . nameForDisplay )
2019-10-11 11:32:21 +02:00
case . unableToRenameFeed ( let from , let to ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Could not rename “%@” to “%@”. " , comment : " Feedly – Could not rename a feed. " )
2019-10-11 11:32:21 +02:00
return String ( format : template , from , to )
2019-10-09 09:38:12 +02:00
case . unableToRemoveFeed ( let feed ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " Could not remove “%@”. " , comment : " Feedly – Could not remove a feed. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , feed . nameForDisplay )
}
}
var recoverySuggestion : String ? {
switch self {
case . notLoggedIn :
return nil
2019-11-25 08:19:33 +01:00
case . unexpectedResourceId :
let template = NSLocalizedString ( " Please contact NetNewsWire support. " , comment : " Feedly – Recovery suggestion for not being able to encode a resource id to send to Feedly.. " )
return String ( format : template )
2019-10-09 09:38:12 +02:00
case . unableToAddFolder :
return nil
case . unableToRenameFolder :
return nil
case . unableToRemoveFolder :
return nil
case . unableToMoveFeedBetweenFolders ( let feed , let from , let to ) :
2019-10-22 12:58:05 +02:00
let template = NSLocalizedString ( " “%@” may be in both “%@” and “%@”. " , comment : " Feedly – Could not move a feed between folders/collections. " )
2019-10-09 09:38:12 +02:00
return String ( format : template , feed . nameForDisplay , from . nameForDisplay , to . nameForDisplay )
case . addFeedChooseFolder :
return nil
case . addFeedInvalidFolder :
2019-10-22 12:58:05 +02:00
return NSLocalizedString ( " Please choose a different folder to contain the feed. " , comment : " Feedly – Feed can only be added to folders recovery suggestion. " )
2019-10-09 09:38:12 +02:00
case . unableToRemoveFeed :
return nil
2019-10-11 11:32:21 +02:00
case . unableToRenameFeed :
return nil
2019-10-09 09:38:12 +02:00
}
}
}