diff --git a/frontend/src/app.d.ts b/frontend/src/app.d.ts index 9176095..d4759fd 100644 --- a/frontend/src/app.d.ts +++ b/frontend/src/app.d.ts @@ -1,8 +1,15 @@ // See https://kit.svelte.dev/docs/types#app + +import type { ErrorCode } from "$lib/api/entities"; + // for information about these interfaces declare global { namespace App { - // interface Error {} + interface Error { + code: ErrorCode; + message?: string | undefined; + details?: string | undefined; + } // interface Locals {} // interface PageData {} // interface Platform {} diff --git a/frontend/src/routes/+error.svelte b/frontend/src/routes/+error.svelte index 21dc4d0..9d7d887 100644 --- a/frontend/src/routes/+error.svelte +++ b/frontend/src/routes/+error.svelte @@ -1,17 +1,20 @@
The page you were looking for was not found. If you're sure the page exists, check for any typos in the address.
-{:else if $page.status === 429} +{:else if $page.error?.code === ErrorCode.Forbidden || $page.error?.code === ErrorCode.InvalidToken} +You're not logged in, or you aren't allowed to access this page.
+{:else if $page.error?.code === 429}You've exceeded a rate limit, please try again later.
-{:else if $page.status === 500} +{:else if $page.error?.code === 500}An internal error occurred. Please try again later.
If this error keeps happening, please
{/if}
- Error message: Error code: The user you were looking for couldn't be found. Please check for any typos. You've exceeded a rate limit, please try again later. An internal error occurred. Please try again later.
- If this error keeps happening, please file a bug report with an explanation of what you did to cause the error.
+ Either you aren't logged in, or your login has expired. Please log in again.
Error message: The user you were looking for couldn't be found. Please check for any typos. You've exceeded a rate limit, please try again later. An internal error occurred. Please try again later.
+ If this error keeps happening, please file a bug report with an explanation of what you did to cause the error.
+ Error message:
- Your profile is empty! You can customize it by going to the edit profile page. (only you can see this)
diff --git a/frontend/src/routes/@[username]/[memberName]/+page.server.ts b/frontend/src/routes/@[username]/[memberName]/+page.server.ts
index ab41c47..9b14e70 100644
--- a/frontend/src/routes/@[username]/[memberName]/+page.server.ts
+++ b/frontend/src/routes/@[username]/[memberName]/+page.server.ts
@@ -14,9 +14,9 @@ export const load = async ({ params }) => {
(e as APIError).code === ErrorCode.UserNotFound ||
(e as APIError).code === ErrorCode.MemberNotFound
) {
- throw error(404, (e as APIError).message);
+ throw error(404, e as APIError);
}
- throw error(500, (e as APIError).message);
+ throw error(500, e as APIError);
}
};
diff --git a/frontend/src/routes/@[username]/edit/+layout.ts b/frontend/src/routes/@[username]/edit/+layout.ts
index 894eb83..2fd9c4c 100644
--- a/frontend/src/routes/@[username]/edit/+layout.ts
+++ b/frontend/src/routes/@[username]/edit/+layout.ts
@@ -1,23 +1,28 @@
import type { PrideFlag, APIError, MeUser, PronounsJson } from "$lib/api/entities";
import { apiFetchClient } from "$lib/api/fetch";
-import { error } from "@sveltejs/kit";
+import { error, redirect, type Redirect } from "@sveltejs/kit";
import pronounsRaw from "$lib/pronouns.json";
const pronouns = pronounsRaw as PronounsJson;
export const ssr = false;
-export const load = async () => {
+export const load = async ({ params }) => {
try {
const user = await apiFetchClient
{$page.error?.message}
{$page.error?.code}
An error occurred ({$page.status})
-
-{#if $page.status === 404}
- Not logged in
An error occurred ({$page.status})
-{$page.error?.message}
{$page.error?.message}
{/if}
- To change your avatar, go to edit profile.
+ To change your avatar, go to edit profile.