-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: revamp error management to make it more robust
- option to return to previous page on errors (javascript only feature essentially) - better handling of different cases - handle error messages the same way if it's a page / server / action error - properly handle query errors - allow error page to possess i18nPayload data - allow `error` sveltekit helper to accept i18nPayload data - properly handle tsRestResult when not ok (error shown shouldn't be only the status number, but the actual error message) - prevent redirect loop when redirecting from error (will use the error helper instead of the redirect if a redirect loop is detected)
- Loading branch information
Showing
13 changed files
with
149 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
import { navigating } from '$app/stores'; | ||
import type { SessionUser } from '$auth/auth-handler'; | ||
import { writable } from 'svelte/store'; | ||
import { reconstructUrl } from '$lib/utils/urls'; | ||
import { readable, writable } from 'svelte/store'; | ||
import { createStoreContext } from './utils/context'; | ||
import { useToggleable } from './utils/toggleable'; | ||
|
||
export const isDrawerHidden = useToggleable(writable(true), (drawerOpenStore) => drawerOpenStore.update((isOpen) => !isOpen)); | ||
|
||
export const { getStore: getSessionUser, setStore: setSessionUser } = createStoreContext<SessionUser>(); | ||
|
||
export const previousPage = readable<string | undefined>(undefined, (set) => { | ||
const unsubscribe = navigating.subscribe(($navigating) => { | ||
// Check if `$navigating` has a value | ||
// because it's set to `null` after navigation is done | ||
if ($navigating) { | ||
const fromUrl = $navigating.from?.url; | ||
|
||
if (!fromUrl) { | ||
set(undefined); | ||
} else { | ||
set(reconstructUrl(fromUrl)); | ||
} | ||
} | ||
}); | ||
|
||
return () => unsubscribe(); | ||
}); | ||
|
||
export * from './theme'; | ||
export * from './utils/matchMedia'; | ||
export * from './utils/storage/local-storage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters