mejores errores

This commit is contained in:
Cat /dev/Nulo 2024-09-14 20:36:08 -03:00
parent ddb202dc93
commit 4db1f0b09e
2 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,26 @@
<script lang="ts">
import { page } from '$app/stores';
import Button from '$lib/components/ui/button/button.svelte';
import { ArrowLeftIcon, HomeIcon } from 'lucide-svelte';
</script>
<div class="mx-auto flex max-w-screen-sm flex-col items-center justify-center gap-4 p-4">
<h1 class="flex text-5xl font-bold">Error {$page.status} :(</h1>
<p>{$page.error?.message}</p>
<div class="flex gap-2">
<Button
on:click={() => {
window.history.back();
}}
class="flex items-center gap-2"
>
<ArrowLeftIcon class="h-4 w-4" />
Volver
</Button>
<Button variant="outline" href="/" class="flex items-center gap-2">
<HomeIcon class="h-4 w-4" />
Ir al inicio
</Button>
</div>
</div>

View file

@ -2,6 +2,7 @@ import { db } from '$lib/server/db';
import type { PageServerLoad } from './$types';
import { datasets, precios, sucursales } from '$lib/server/db/schema';
import { and, eq, sql } from 'drizzle-orm';
import { error } from '@sveltejs/kit';
export const load: PageServerLoad = async ({ params, setHeaders }) => {
const id = BigInt(params.id);
const preciosRes = await db
@ -51,6 +52,10 @@ ORDER BY d1.id_comercio)
'Cache-Control': 'public, max-age=600'
});
if (preciosRes.length == 0) {
return error(404, `Producto ${params.id} no encontrado`);
}
// const precios = await sql<
// {
// productos_precio_lista: number;