Report .inactiveProfile on nil GracefulVPN.vpn

Methods:

- reconnect
- reinstall
- disconnect
This commit is contained in:
Davide De Rosa 2019-03-10 14:26:09 +01:00
parent f50cf44bab
commit 29f34cd206
2 changed files with 5 additions and 5 deletions

View File

@ -31,4 +31,6 @@ enum ApplicationError: String, Error {
case missingCredentials case missingCredentials
case migration case migration
case inactiveProfile
} }

View File

@ -28,8 +28,6 @@ import SwiftyBeaver
private let log = SwiftyBeaver.self private let log = SwiftyBeaver.self
// FIXME: replace completionHandler?(nil) with completionHandler?(some_error)
class GracefulVPN { class GracefulVPN {
private let service: ConnectionService private let service: ConnectionService
@ -70,7 +68,7 @@ class GracefulVPN {
func reconnect(completionHandler: ((Error?) -> Void)?) { func reconnect(completionHandler: ((Error?) -> Void)?) {
service.clearVpnLastError() service.clearVpnLastError()
guard let vpn = vpn else { guard let vpn = vpn else {
completionHandler?(nil) completionHandler?(ApplicationError.inactiveProfile)
return return
} }
do { do {
@ -84,7 +82,7 @@ class GracefulVPN {
func reinstall(completionHandler: ((Error?) -> Void)?) { func reinstall(completionHandler: ((Error?) -> Void)?) {
service.clearVpnLastError() service.clearVpnLastError()
guard let vpn = vpn else { guard let vpn = vpn else {
completionHandler?(nil) completionHandler?(ApplicationError.inactiveProfile)
return return
} }
do { do {
@ -109,7 +107,7 @@ class GracefulVPN {
func disconnect(completionHandler: ((Error?) -> Void)?) { func disconnect(completionHandler: ((Error?) -> Void)?) {
guard let vpn = vpn else { guard let vpn = vpn else {
completionHandler?(nil) completionHandler?(ApplicationError.inactiveProfile)
return return
} }
vpn.disconnect(completionHandler: completionHandler) vpn.disconnect(completionHandler: completionHandler)