From 6e535f4fc405871446711212e69a5a99ffa16113 Mon Sep 17 00:00:00 2001 From: Giuseppe Stelluto Date: Sun, 21 Jan 2024 17:59:08 +0100 Subject: [PATCH] Throw exception if no login flows found --- src/LoginHandler.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/LoginHandler.ts b/src/LoginHandler.ts index a493b50..38fb6c8 100644 --- a/src/LoginHandler.ts +++ b/src/LoginHandler.ts @@ -95,16 +95,24 @@ export default class LoginHandler { base_url = "https://" + name; } finally { this.base_url = base_url; + try { + shared.mClient = createClient({ + baseUrl: base_url, + fetchFn: customFetch, + }); + let result = await shared.mClient.loginFlows() + if (! result.flows) { + throw new Error("Got no flows"); + } + this.loginFlows = result.flows; + } catch (e) { + alert(`No server found at ${base_url}`) + console.log(e); + } this.setWellKnown({ "m.homeserver": {"base_url": base_url}, "m.identity_server": {"base_url": "https://vector.im"}, // TODO Where to infer this outside of actual .well-known? }) - shared.mClient = createClient({ - baseUrl: base_url, - fetchFn: customFetch, - }); - let result = await shared.mClient.loginFlows() - this.loginFlows = result.flows; } } }