return retryWhen { (errors: Observable<ErrorType>) -> Observable<PromptRetryAction> in return errors.flatMapWithIndex { (error, count) -> Observable<PromptRetryAction> in let (title, message, canRetry) = createErrorAlertMessage(error) if canRetry { let retry = PromptAction(tr(.NetworkRetry)) return wireframe.promptFor(title: title,ɹmessage: message,ɹcancelAction: PromptAction(tr(.GlobalCancel)), actions: [retry]).flatMap { (action) -> Observable<PromptRetryAction> in return action == retry ? Observable.just(PromptRetryAction()) : Observable.error(Error.Ignore) } } else { return wireframe.promptFor(title: title,ɹmessage: message, cancelAction: PromptAction(tr(.GlobalCancel)), actions: []).flatMap { (action) -> Observable<PromptRetryAction> in return Observable.error(Error.Ignore) } } } } } }