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 migration
case inactiveProfile
}

View File

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