Present error alert on missing provider (#766)

This commit is contained in:
Davide 2024-10-28 20:30:22 +01:00 committed by GitHub
parent 11a0f95cdd
commit 7ede841346
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 28 additions and 11 deletions

View File

@ -41,7 +41,7 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source",
"state" : { "state" : {
"revision" : "d21f1b362dfe667c36483e18b2dbb494bba54660" "revision" : "db0f5258fdbd5192dd2b87dedc46494494bc7ffb"
} }
}, },
{ {

View File

@ -28,7 +28,7 @@ let package = Package(
], ],
dependencies: [ dependencies: [
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "d21f1b362dfe667c36483e18b2dbb494bba54660"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "db0f5258fdbd5192dd2b87dedc46494494bc7ffb"),
// .package(path: "../../../passepartoutkit-source"), // .package(path: "../../../passepartoutkit-source"),
.package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"),
// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"),

View File

@ -56,9 +56,6 @@ extension PassepartoutError: LocalizedError {
return Strings.Errors.App.Passepartout.connectionModuleRequired return Strings.Errors.App.Passepartout.connectionModuleRequired
case .corruptProviderModule: case .corruptProviderModule:
if let ppReason = reason as? PassepartoutError, ppReason.code == .notFound {
return Strings.Errors.App.Provider.missingEntity
}
return Strings.Errors.App.Passepartout.corruptProviderModule(reason?.localizedDescription ?? "") return Strings.Errors.App.Passepartout.corruptProviderModule(reason?.localizedDescription ?? "")
case .incompatibleModules: case .incompatibleModules:
@ -84,6 +81,9 @@ extension PassepartoutError: LocalizedError {
.compactMap { $0 } .compactMap { $0 }
.joined(separator: " ") .joined(separator: " ")
case .providerRequired:
return Strings.Errors.App.Passepartout.providerRequired
case .unhandled: case .unhandled:
return reason?.localizedDescription return reason?.localizedDescription

View File

@ -133,12 +133,16 @@ public enum Strings {
public static let incompatibleModules = Strings.tr("Localizable", "errors.app.passepartout.incompatible_modules", fallback: "Some active modules are incompatible, try to only activate one of them.") public static let incompatibleModules = Strings.tr("Localizable", "errors.app.passepartout.incompatible_modules", fallback: "Some active modules are incompatible, try to only activate one of them.")
/// Invalid fields. /// Invalid fields.
public static let invalidFields = Strings.tr("Localizable", "errors.app.passepartout.invalid_fields", fallback: "Invalid fields.") public static let invalidFields = Strings.tr("Localizable", "errors.app.passepartout.invalid_fields", fallback: "Invalid fields.")
/// No provider server selected.
public static let missingProviderEntity = Strings.tr("Localizable", "errors.app.passepartout.missing_provider_entity", fallback: "No provider server selected.")
/// Unable to parse file. /// Unable to parse file.
public static let parsing = Strings.tr("Localizable", "errors.app.passepartout.parsing", fallback: "Unable to parse file.") public static let parsing = Strings.tr("Localizable", "errors.app.passepartout.parsing", fallback: "Unable to parse file.")
/// No provider selected.
public static let providerRequired = Strings.tr("Localizable", "errors.app.passepartout.provider_required", fallback: "No provider selected.")
} }
public enum Provider { public enum Provider {
/// No provider server selected. /// No provider selected.
public static let missingEntity = Strings.tr("Localizable", "errors.app.provider.missing_entity", fallback: "No provider server selected.") public static let `required` = Strings.tr("Localizable", "errors.app.provider.required", fallback: "No provider selected.")
} }
} }
public enum Tunnel { public enum Tunnel {

View File

@ -260,13 +260,15 @@
"errors.app.empty_profile_name" = "Profile name is empty."; "errors.app.empty_profile_name" = "Profile name is empty.";
"errors.app.malformed_module" = "Module %@ is malformed. %@"; "errors.app.malformed_module" = "Module %@ is malformed. %@";
"errors.app.provider.missing_entity" = "No provider server selected."; "errors.app.provider.required" = "No provider selected.";
"errors.app.default" = "Unable to complete operation."; "errors.app.default" = "Unable to complete operation.";
"errors.app.passepartout.connection_module_required" = "Routing module can only be enabled together with a connection."; "errors.app.passepartout.connection_module_required" = "Routing module can only be enabled together with a connection.";
"errors.app.passepartout.corrupt_provider_module" = "Unable to connect to provider server (reason=%@)."; "errors.app.passepartout.corrupt_provider_module" = "Unable to connect to provider server (reason=%@).";
"errors.app.passepartout.invalid_fields" = "Invalid fields.";
"errors.app.passepartout.incompatible_modules" = "Some active modules are incompatible, try to only activate one of them."; "errors.app.passepartout.incompatible_modules" = "Some active modules are incompatible, try to only activate one of them.";
"errors.app.passepartout.invalid_fields" = "Invalid fields.";
"errors.app.passepartout.missing_provider_entity" = "No provider server selected.";
"errors.app.passepartout.parsing" = "Unable to parse file."; "errors.app.passepartout.parsing" = "Unable to parse file.";
"errors.app.passepartout.provider_required" = "No provider selected.";
"errors.app.passepartout.default" = "Unable to complete operation (code=%@)."; "errors.app.passepartout.default" = "Unable to complete operation (code=%@).";
"errors.tunnel.auth" = "Auth failed"; "errors.tunnel.auth" = "Auth failed";

View File

@ -160,7 +160,7 @@ private struct ProviderCountryFlag: View {
var body: some View { var body: some View {
ThemeCountryFlag( ThemeCountryFlag(
code: provider.entity?.header.countryCode, code: provider.entity?.header.countryCode,
placeholderTip: Strings.Errors.App.Provider.missingEntity, placeholderTip: Strings.Errors.App.Passepartout.missingProviderEntity,
countryTip: { countryTip: {
$0.localizedAsRegionCode $0.localizedAsRegionCode
} }

View File

@ -140,9 +140,20 @@ private extension TunnelToggleButton {
} catch is CancellationError { } catch is CancellationError {
// //
} catch { } catch {
if (error as? PassepartoutError)?.code == .missingProviderEntity { switch (error as? PassepartoutError)?.code {
case .missingProviderEntity:
onProviderEntityRequired?(profile) onProviderEntityRequired?(profile)
return return
case .providerRequired:
errorHandler.handle(
error,
title: Strings.Global.connection
)
return
default:
break
} }
errorHandler.handle( errorHandler.handle(
error, error,