summaryrefslogtreecommitdiff
path: root/kcore/error.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-12-24 19:20:25 +0100
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-12-24 19:20:25 +0100
commitc1b78bf43b1f20706c787061d7238e7acd8b5b2d (patch)
tree936dba9ae768c0fedf4456db4d0392826072ccff /kcore/error.go
parent6d05a64a0a40df152b218d76c9247c1aa743c879 (diff)
Implements Must function and enhances Unauthorized handlerv0.7.0
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.
Diffstat (limited to 'kcore/error.go')
-rw-r--r--kcore/error.go7
1 files changed, 7 insertions, 0 deletions
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
+}