diff --git a/Shared/Account/AccountLoginView.swift b/Shared/Account/AccountLoginView.swift index 05d2384..d420aa1 100644 --- a/Shared/Account/AccountLoginView.swift +++ b/Shared/Account/AccountLoginView.swift @@ -62,7 +62,6 @@ struct AccountLoginView: View { if !(server.hasPrefix("https://") || server.hasPrefix("http://")) { server = "https://\(server)" } - print(server) // We only need the protocol and host from the URL, so drop anything else. let url = URLComponents(string: server) if let validURL = url { @@ -73,7 +72,8 @@ struct AccountLoginView: View { hostURL.host = host server = hostURL.string ?? server } else { - // TODO: - throw an error if this is an invalid URL. + model.loginErrorMessage = AccountError.invalidServerURL.localizedDescription + model.isPresentingLoginErrorAlert = true } model.login( to: URL(string: server)!, diff --git a/Shared/Account/AccountModel.swift b/Shared/Account/AccountModel.swift index 25683a5..0010a44 100644 --- a/Shared/Account/AccountModel.swift +++ b/Shared/Account/AccountModel.swift @@ -5,6 +5,7 @@ enum AccountError: Error { case invalidPassword case usernameNotFound case serverNotFound + case invalidServerURL } extension AccountError: LocalizedError { @@ -25,6 +26,11 @@ extension AccountError: LocalizedError { "Username not found. Did you use your email address by mistake?", comment: "" ) + case .invalidServerURL: + return NSLocalizedString( + "The server entered doesn't appear to be a valid URL. Please check what you've entered and try again.", + comment: "" + ) } } }