mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-10-29 23:19:56 +00:00
mejores errores
This commit is contained in:
parent
ddb202dc93
commit
4db1f0b09e
2 changed files with 31 additions and 0 deletions
26
sepa/sitio2/src/routes/+error.svelte
Normal file
26
sepa/sitio2/src/routes/+error.svelte
Normal 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>
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue