Handler errors throw instead of returning styled divs
api and call-handler now use (error ...) for not-found and method mismatch, so error boundaries catch them properly instead of rendering error messages as page content. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,10 +6,7 @@
|
|||||||
((handler-key (str "handler:ex-" slug)) (hdef (env-get handler-key)))
|
((handler-key (str "handler:ex-" slug)) (hdef (env-get handler-key)))
|
||||||
(if
|
(if
|
||||||
(nil? hdef)
|
(nil? hdef)
|
||||||
(div
|
(error (str "Handler not found: " handler-key))
|
||||||
:class "p-8"
|
|
||||||
(h2 :class "text-rose-600 font-semibold" "Handler not found")
|
|
||||||
(p :class "text-stone-500" (str "No handler: " handler-key)))
|
|
||||||
(call-handler hdef)))))
|
(call-handler hdef)))))
|
||||||
|
|
||||||
(define
|
(define
|
||||||
@@ -28,8 +25,7 @@
|
|||||||
(and
|
(and
|
||||||
(not (= handler-method "GET"))
|
(not (= handler-method "GET"))
|
||||||
(not (= req-method handler-method)))
|
(not (= req-method handler-method)))
|
||||||
(div
|
(error
|
||||||
:class "p-4 text-rose-600"
|
|
||||||
(str
|
(str
|
||||||
"Method not allowed: expected "
|
"Method not allowed: expected "
|
||||||
handler-method
|
handler-method
|
||||||
|
|||||||
Reference in New Issue
Block a user