diff --git a/web/src/app.d.ts b/web/src/app.d.ts
index 13619596b2..46398aad3c 100644
--- a/web/src/app.d.ts
+++ b/web/src/app.d.ts
@@ -8,6 +8,12 @@ declare namespace App {
}
// interface Platform {}
+
+ interface Error {
+ message: string;
+ stack?: string;
+ code?: string;
+ }
}
// Source: https://stackoverflow.com/questions/63814432/typescript-typing-of-non-standard-window-event-in-svelte
diff --git a/web/src/hooks.server.ts b/web/src/hooks.server.ts
index f061284480..0ed93b7b9e 100644
--- a/web/src/hooks.server.ts
+++ b/web/src/hooks.server.ts
@@ -1,5 +1,15 @@
-import type { Handle } from '@sveltejs/kit';
+import type { Handle, HandleServerError } from '@sveltejs/kit';
+import { AxiosError } from 'axios';
export const handle: Handle = async ({ event, resolve }) => {
return await resolve(event);
};
+
+export const handleError: HandleServerError = async ({ error }) => {
+ const httpError = error as AxiosError;
+ return {
+ message: httpError?.message || 'Hmm, not sure about that. Check the logs or open a ticket?',
+ stack: httpError?.stack,
+ code: httpError.code || '500'
+ };
+};
diff --git a/web/src/lib/components/forms/login-form.svelte b/web/src/lib/components/forms/login-form.svelte
index 07ebf88c76..33ba0598a8 100644
--- a/web/src/lib/components/forms/login-form.svelte
+++ b/web/src/lib/components/forms/login-form.svelte
@@ -2,6 +2,7 @@
import { goto } from '$app/navigation';
import LoadingSpinner from '$lib/components/shared-components/loading-spinner.svelte';
import { loginPageMessage } from '$lib/constants';
+ import { handleError } from '$lib/utils/handle-error';
import { api, oauth, OAuthConfigResponseDto } from '@api';
import { createEventDispatcher, onMount } from 'svelte';
@@ -9,7 +10,7 @@
let email = '';
let password = '';
let oauthError: string;
- let oauthConfig: OAuthConfigResponseDto = { enabled: false, passwordLoginEnabled: false };
+ let authConfig: OAuthConfigResponseDto = { enabled: false, passwordLoginEnabled: false };
let loading = true;
const dispatch = createEventDispatcher();
@@ -30,17 +31,18 @@
try {
const { data } = await oauth.getConfig(window.location);
- oauthConfig = data;
+ authConfig = data;
- const { enabled, url, autoLaunch } = oauthConfig;
+ const { enabled, url, autoLaunch } = authConfig;
if (enabled && url && autoLaunch && !oauth.isAutoLaunchDisabled(window.location)) {
await goto('/auth/login?autoLaunch=0', { replaceState: true });
await goto(url);
return;
}
- } catch (e) {
- console.error('Error [login-form] [oauth.generateConfig]', e);
+ } catch (error) {
+ authConfig.passwordLoginEnabled = true;
+ handleError(error, 'Unable to connect!');
}
loading = false;
@@ -92,7 +94,7 @@