diff --git a/src/lib/owlClient.ts b/src/lib/owlClient.ts
index d9f66f1..33d7198 100644
--- a/src/lib/owlClient.ts
+++ b/src/lib/owlClient.ts
@@ -31,6 +31,7 @@ export function ThrowApiError(e: unknown): never {
// Map ApiError 'code' values
if (e instanceof ApiError) {
+ console.error(JSON.stringify(e), e.code, "ERRCODE")
let status = 500;
if (e.code === 'AUTH') {
status = 401;
@@ -53,6 +54,7 @@ export function ThrowApiError(e: unknown): never {
// Fallback for other error kind
const genericMessage = e instanceof Error ? e.message : 'An unexpected error occurred.';
+ console.log(e)
throw error(500, {
message: genericMessage,
name: 'CRITICAL_ERROR',
diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte
index 8cbe428..de9a8d3 100644
--- a/src/routes/+error.svelte
+++ b/src/routes/+error.svelte
@@ -4,26 +4,35 @@
import stopErr from '$lib/assets/img/stop-error.svg';
import noResult from '$lib/assets/img/no-data.svg';
import Button from '$lib/components/ui/form-elements/Button.svelte';
+ import { IconAntennaBarsOff } from '@tabler/icons-svelte-runes';
-{#if page.error}
+
- {#if page.status == 404}
-
-

- {:else if page.status == 503}
-
-
OFFLINE!
-

- {:else if page.status == 403}
-
UNAUTH
-

+ {#if page.error?.code}
+ {#if page.error.code === 'NOT_FOUND'}
+

+ {:else if page.error.code === 'RATE_LIMIT'}
+

+ {:else if page.error.code === 'VALIDATION'}
+

+ {:else if page.error.code === 'AUTH'}
+

+ {:else if page.error.code === 'SERVER'}
+

+ {:else if page.error.code === 'NETWORK_DISCONNECTED'}
+
+
+
+ {:else}
+

+ {/if}
{:else}

@@ -34,17 +43,16 @@
{page.error?.message ?? 'An unexpected derailment occurred.'}
- {#if page.error?.owlCode == 'NETWORK_DISCONNECTED'}
-
THISISANETWORKERR
-
Operational data is unavaliable when offline
- {:else}
+ {#if page.error?.code}
- Ref: {page.error?.owlCode}
+ Ref: {page.error.code}
{/if}
- {#if page.error?.owlCode === 'NETWORK_DISCONNECTED'}
+ {#if page.error?.code === 'NETWORK_DISCONNECTED'}
+ {:else if page.error?.code === 'NOT_FOUND'}
+
{:else}
{/if}
@@ -75,6 +83,19 @@
}
}
+ @keyframes gentle-flash {
+ 100% {
+ opacity: 1;
+ }
+ 50% {
+ opacity: 0.25;
+ }
+ }
+
+ .gentle-flash {
+ animation: gentle-flash ease-in-out 2s infinite;
+ }
+
.label {
color: #ff4444;
letter-spacing: 0.2rem;
diff --git a/src/routes/board/+page.ts b/src/routes/board/+page.ts
index 2da8c3d..07f0ce1 100644
--- a/src/routes/board/+page.ts
+++ b/src/routes/board/+page.ts
@@ -12,7 +12,7 @@ export const load: PageLoad = async ({ url, fetch }) => {
if (!locId) {
error(400, {
message: 'Location not provided',
- owlCode: 'NO_LOCATION_IN_PATH'
+ code: 'VALIDATION'
});
}
@@ -21,7 +21,7 @@ export const load: PageLoad = async ({ url, fetch }) => {
if (!BoardLocation) {
error(404, {
message: `Location (${locId.toUpperCase()}) not found`,
- owlCode: 'INVALID_LOCATION_CODE'
+ code: 'VALIDATION'
});
}
const title = BoardLocation.n || BoardLocation.t || 'Live Arr/Dep';
@@ -35,12 +35,6 @@ export const load: PageLoad = async ({ url, fetch }) => {
boardData
};
} catch (e: unknown) {
- if (e instanceof TypeError && e.message === 'Failed to fetch') {
- error(503, {
- message: 'Cannot connect to the OwlBoard server',
- owlCode: 'NETWORK_DISCONNECTED'
- });
- }
throw e;
}
};
diff --git a/src/routes/trains/+page.ts b/src/routes/trains/+page.ts
index d7bdc72..af32738 100644
--- a/src/routes/trains/+page.ts
+++ b/src/routes/trains/+page.ts
@@ -1,7 +1,6 @@
import { OwlClient, ApiError, ValidationError, ThrowApiError } from '$lib/owlClient';
import type { ApiTrainsTrainByHeadcode } from '@owlboard/owlboard-ts';
import type { PageLoad } from './$types';
-import { error } from '@sveltejs/kit';
export const load: PageLoad = async ({ fetch, url }) => {
const headcode = url.searchParams.get('h');