Add trivial-backtrace

This commit is contained in:
Akira Tempaku 2024-04-20 03:02:38 +09:00
parent 47bc8cc9ee
commit 4949324e05
4 changed files with 14 additions and 3 deletions

1
qlfile
View file

@ -6,3 +6,4 @@ git ningle-fbr https://github.com/skyizwhite/ningle-fbr.git
ql cl-ppcre
ql log4cl
ql function-cache
ql trivial-backtrace

View file

@ -34,3 +34,7 @@
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2023-10-21"))
("trivial-backtrace" .
(:class qlot/source/ql:source-ql
:initargs (:%version :latest)
:version "ql-2023-10-21"))

View file

@ -1,8 +1,7 @@
(defpackage #:hp/config
(:use #:cl)
(:import-from #:log4cl)
(:export #:*env*
#:dev-mode-p
(:export #:dev-mode-p
#:prod-mode-p))
(in-package #:hp/config)

View file

@ -1,9 +1,16 @@
(defpackage #:hp/middlewares/recovery
(:use #:cl)
(:import-from #:log4cl)
(:local-nicknames (#:tb #:trivial-backtrace))
(:local-nicknames (#:cfg #:hp/config))
(:export #:*recovery*))
(in-package #:hp/middlewares/recovery)
(defun message (condition)
(if (cfg:dev-mode-p)
(tb:print-backtrace condition :output nil)
"Internal Server Error"))
(defparameter *recovery*
(lambda (app)
(lambda (env)
@ -12,4 +19,4 @@
(error (c)
(log:error "Unhandled error caught: ~a" c)
`(500 (:content-type "text/plain")
("Internal Server Error")))))))
(,(message c))))))))