Skip to content

Commit

Permalink
Stop logging errors on 404
Browse files Browse the repository at this point in the history
  • Loading branch information
isker committed Oct 8, 2023
1 parent d72c763 commit 967c564
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { building } from "$app/environment";
import { resolveConfiguration } from "$lib/server/configuration";
import type { HandleServerError } from "@sveltejs/kit";

if (!building) {
// Resolve the configuration on startup, such that startup fails if the
Expand All @@ -13,5 +14,10 @@ if (!building) {
// TODO we should have prom metrics, on, among other things, HTTP requests
// handled, and the `handle` hook would be a good way to do that.

// TODO SvelteKit logs an error every time anything requests a URL that does not
// map to a route. Bonkers. Silence those by implementing `handleError`.
// SvelteKit logs an error every time anything requests a URL that does not map
// to a route. Bonkers. Override the default behavior to exclude such cases.
export const handleError: HandleServerError = ({ error, event }) => {
if (event.route.id !== null) {
console.error(error);
}
};

0 comments on commit 967c564

Please sign in to comment.