diff --git a/sepa/sitio2/src/routes/+error.svelte b/sepa/sitio2/src/routes/+error.svelte new file mode 100644 index 0000000..6570241 --- /dev/null +++ b/sepa/sitio2/src/routes/+error.svelte @@ -0,0 +1,26 @@ + + +
+

Error {$page.status} :(

+

{$page.error?.message}

+ +
+ + +
+
diff --git a/sepa/sitio2/src/routes/id_producto/[id]/+page.server.ts b/sepa/sitio2/src/routes/id_producto/[id]/+page.server.ts index e08e8d9..12e9ca9 100644 --- a/sepa/sitio2/src/routes/id_producto/[id]/+page.server.ts +++ b/sepa/sitio2/src/routes/id_producto/[id]/+page.server.ts @@ -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;