Improve error handling
This commit is contained in:
4
src/app.d.ts
vendored
4
src/app.d.ts
vendored
@@ -4,7 +4,9 @@ declare global {
|
|||||||
namespace App {
|
namespace App {
|
||||||
interface Error {
|
interface Error {
|
||||||
message: string;
|
message: string;
|
||||||
owlCode?: string;
|
code?: string;
|
||||||
|
name?: string;
|
||||||
|
msg?: string;
|
||||||
}
|
}
|
||||||
// interface Locals {}
|
// interface Locals {}
|
||||||
// interface PageData {}
|
// interface PageData {}
|
||||||
|
|||||||
11
src/hooks.client.ts
Normal file
11
src/hooks.client.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import type { HandleClientError } from "@sveltejs/kit";
|
||||||
|
|
||||||
|
export const handleError: HandleClientError = ({ error }) => {
|
||||||
|
const err = error as any;
|
||||||
|
|
||||||
|
return {
|
||||||
|
message: err?.message || 'An unexpected application error occurred.',
|
||||||
|
code: err?.code || 'CRITICAL',
|
||||||
|
msg: err?.msg || 'UNHANDLED_EXCEPTION'
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -18,4 +18,6 @@ export const OwlClient = new OwlBoardClient(
|
|||||||
// API Key Here when ready!!!
|
// API Key Here when ready!!!
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export function ThrowApiError(e: any): void {}
|
||||||
|
|
||||||
export { ValidationError, ApiError };
|
export { ValidationError, ApiError };
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
|
|
||||||
<!-- Will need to check error type, using the upstream code combined with response code -->
|
<!-- Will need to check error type, using the upstream code combined with response code -->
|
||||||
|
|
||||||
|
{#if page.error}
|
||||||
|
{JSON.stringify(page.error)}
|
||||||
|
STATUS: {page.status}
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="error-wrapper">
|
<div class="error-wrapper">
|
||||||
{#if page.status == 404}
|
{#if page.status == 404}
|
||||||
<!-- Warning no data image -->
|
<!-- Warning no data image -->
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
<!-- Dynamic Nav Elements Here! -->
|
<!-- Dynamic Nav Elements Here! -->
|
||||||
{#each visibleItems as item}
|
{#each visibleItems as item}
|
||||||
{@const isActive = activePath.replace(/\/$/, '') === item.path.replace(/\/$/, '')}
|
{@const isActive = activePath.replace(/\/$/, '') === item.path.replace(/\/$/, '')}
|
||||||
|
{@const Icon = item.icon}
|
||||||
<a
|
<a
|
||||||
href={item.path}
|
href={item.path}
|
||||||
class="nav-item"
|
class="nav-item"
|
||||||
@@ -113,7 +114,7 @@
|
|||||||
aria-current={isActive ? 'page' : undefined}
|
aria-current={isActive ? 'page' : undefined}
|
||||||
onclick={() => (menuOpen = false)}
|
onclick={() => (menuOpen = false)}
|
||||||
>
|
>
|
||||||
<item.icon size={24} stroke={isActive ? 2 : 1.5} class="nav-icon" />
|
<Icon size={24} stroke={isActive ? 2 : 1.5} class="nav-icon" />
|
||||||
|
|
||||||
<span class="label">{item.label}</span>
|
<span class="label">{item.label}</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -138,6 +139,7 @@
|
|||||||
<div class="menu-popover" transition:slide={{ axis: 'y', duration: 250 }}>
|
<div class="menu-popover" transition:slide={{ axis: 'y', duration: 250 }}>
|
||||||
{#each hiddenItems as item}
|
{#each hiddenItems as item}
|
||||||
{@const isActive = activePath.replace(/\/$/, '') === item.path.replace(/\/$/, '')}
|
{@const isActive = activePath.replace(/\/$/, '') === item.path.replace(/\/$/, '')}
|
||||||
|
{@const Icon = item.icon}
|
||||||
<a
|
<a
|
||||||
href={item.path}
|
href={item.path}
|
||||||
class="menu-popover-item"
|
class="menu-popover-item"
|
||||||
@@ -145,7 +147,7 @@
|
|||||||
class:active={isActive}
|
class:active={isActive}
|
||||||
aria-current={isActive ? 'page' : undefined}
|
aria-current={isActive ? 'page' : undefined}
|
||||||
>
|
>
|
||||||
<item.icon size={20} />
|
<Icon size={20} />
|
||||||
<span>{item.label}</span>
|
<span>{item.label}</span>
|
||||||
</a>
|
</a>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
Reference in New Issue
Block a user