/
dimamir
/
rill
Обзор
Документация
Войти
/
dimamir
/
rill
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
web-admin/src/features/errors/error-store.ts
40 строк
997 B
Eric P Green
Cloud UI: Add page for shareable link via magic token (#5163)
03 июл 2024, 19:20
Не верифицирован
03 июл 2024, 19:20
d4aaf25
Код
Авторство
О чём код?
/** * The `errorStore` holds the state of any runtime errors, which * the `ErrorBoundary` component catches and routes to the `ErrorPage`. */ import { derived, writable, type Writable } from "svelte/store"; export interface ErrorStoreState { statusCode: number | null; header: string; body: string; detail?: string; fatal?: boolean; } export interface ErrorStore extends Writable<ErrorStoreState> { reset: () => void; } const createErrorStore = (): ErrorStore => { const { subscribe, set, update } = writable({ statusCode: null, header: "", body: "", fatal: false, }); const reset = (): void => { set({ statusCode: null, header: "", body: "", fatal: false }); }; return { subscribe, set, update, reset }; }; export const errorStore = createErrorStore(); export const isErrorStoreEmpty = derived(errorStore, ($errorStore) => { const { statusCode, header, body } = $errorStore; return statusCode === null && header === "" && body === ""; });