From c1b78bf43b1f20706c787061d7238e7acd8b5b2d Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Wed, 24 Dec 2025 19:20:25 +0100 Subject: Implements Must function and enhances Unauthorized handler Adds the Must function for error handling, simplifying code by allowing panic on errors. Improves the Unauthorized handler to ensure proper error reporting when writing responses. --- kcore/error.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'kcore/error.go') diff --git a/kcore/error.go b/kcore/error.go index fad5f3d..3e4ee1f 100644 --- a/kcore/error.go +++ b/kcore/error.go @@ -29,3 +29,10 @@ func Assert(cond bool, msg string) { panic(err) } } + +func Must[T any](val T, err error) T { + if err != nil { + panic(err) + } + return val +} -- cgit v1.3