Is there any straightforward way to get a backtrace-on-error displayed on the browser screen instead of being logged to a file, like Pythons' cgitb package does? I tried this:
(defun error-handler (arg) [code-to-generate-backtrace])
(setf *HTTP-ERROR-HANDLER* 'error-handler)
but that doesn't work because by the time error-handler is called the server has already exited the error context.
Thanks, rg
Hunchentoot already depends om trivial-backtrace, so it should be pretty trivial to wrap a handler-bind around your code to make it do what you want.
Having said that, we used to have an option to do that automatically (controlled by a special variable) which was removed during The Big Cleanup[TM]. If someone wants to send a patch to add this back in, I'll likely accept that.
Edi.
On Sat, Aug 28, 2010 at 3:50 AM, Ron Garret ron@flownet.com wrote:
Is there any straightforward way to get a backtrace-on-error displayed on the browser screen instead of being logged to a file, like Pythons' cgitb package does? I tried this:
(defun error-handler (arg) [code-to-generate-backtrace])
(setf *HTTP-ERROR-HANDLER* 'error-handler)
but that doesn't work because by the time error-handler is called the server has already exited the error context.
Thanks, rg
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel
On Sat, Aug 28, 2010 at 12:20, Edi Weitz edi@agharta.de wrote:
Hunchentoot already depends om trivial-backtrace, so it should be pretty trivial to wrap a handler-bind around your code to make it do what you want.
Having said that, we used to have an option to do that automatically (controlled by a special variable) which was removed during The Big Cleanup[TM]. If someone wants to send a patch to add this back in, I'll likely accept that.
I've commited http://bknr.net/trac/changeset/4603 to revive *SHOW-LISP-BACKTRACES-P*
-Hans
On Sun, Aug 29, 2010 at 8:55 AM, Hans Hübner hans.huebner@gmail.com wrote:
I've commited http://bknr.net/trac/changeset/4603 to revive *SHOW-LISP-BACKTRACES-P*
Thanks... :)
Ron Garret wrote:
Is there any straightforward way to get a backtrace-on-error displayed on the browser screen instead of being logged to a file, like Pythons' cgitb package does? I tried this:
(defun error-handler (arg) [code-to-generate-backtrace])
(setf *HTTP-ERROR-HANDLER* 'error-handler)
but that doesn't work because by the time error-handler is called the server has already exited the error context.
Here's what we're using in Weblocks:
http://bitbucket.org/S11001001/weblocks-dev/src/tip/src/request-handler.lisp... http://bitbucket.org/S11001001/weblocks-dev/src/tip/src/error-handler.lisp#c...
HTH,
Leslie
Thanks!
Here's what I came up with that seems to work:
(defvar *devel-mode* nil)
(defun devel-mode-handler (condition) (when *devel-mode* (throw 'page-handler-done (format nil "<h1>Error</h1>~%~A<br>~%<pre>~%~A~%<pre>~%" condition (html-escape (tbnl::get-backtrace))))))
(defmacro defpage (url &body body) ... (catch 'page-handler-done (handler-bind ((error 'devel-mode-handler)) (html :page ,@body)))))))
rg
On Aug 28, 2010, at 4:29 AM, Leslie P. Polzer wrote:
Ron Garret wrote:
Is there any straightforward way to get a backtrace-on-error displayed on the browser screen instead of being logged to a file, like Pythons' cgitb package does? I tried this:
(defun error-handler (arg) [code-to-generate-backtrace])
(setf *HTTP-ERROR-HANDLER* 'error-handler)
but that doesn't work because by the time error-handler is called the server has already exited the error context.
Here's what we're using in Weblocks:
http://bitbucket.org/S11001001/weblocks-dev/src/tip/src/request-handler.lisp... http://bitbucket.org/S11001001/weblocks-dev/src/tip/src/error-handler.lisp#c...
HTH,
Leslie
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel