[hunchentoot-devel] Invoke-debugger
Peter Seibel
peter at gigamonkeys.com
Fri Nov 13 17:10:21 UTC 2009
On Fri, Nov 13, 2009 at 8:45 AM, Hans Hübner <hans.huebner at gmail.com> wrote:
> On Fri, Nov 13, 2009 at 17:37, Frode V. Fjeld <frode at netfonds.no> wrote:
>> It's rather easy to modify the standard process-request to call
>> invoke-debugger, but wouldn't it make sense to have something like
>> hunchentoot:*invoke-debugger-on-error-p* ?
>
> This is a common question which has been discussed a number of times.
> We've meant to put some debugging hints into the documentation, yet
> we've failed to do so, sorry about that.
>
> The answer is: Use *break-on-signals* to have your Lisp enter the
> debugger when a certain condition type is signalled. See
> http://l1sp.org/cl/*break-on-signals* for details.
>
> Hunchentoot used to have a special variable like you suggested, but we
> felt that it is better to use the language facilities rather than to
> invent special purpose mechanisms. Learning how to use
> *break-on-signals* is something that is useful anyway, so please try
> it out to see if it fits your needs.
In case *break-on-signals* doesn't meet your needs (for instance, if
there are a lot of errors that get signaled and handled that can't be
distinguished by type from the errors you want to go into the debugger
on, you can also use something like this code which I got from someone
on #lisp (antifuch's maybe?)
;;; An acceptor that invokes the debugger on errors:
(defclass debuggable-acceptor (hunchentoot:acceptor)
())
(defvar *debug-connections* nil)
(defmethod process-connection ((*acceptor* debuggable-acceptor) (socket t))
(declare (ignore socket))
(if *debug-connections*
(handler-bind ((error #'invoke-debugger))
(call-next-method))
(call-next-method)))
(defmethod acceptor-request-dispatcher ((*acceptor* debuggable-acceptor))
(let ((dispatcher (call-next-method)))
(lambda (request)
(handler-bind ((error #'invoke-debugger))
(funcall dispatcher request)))))
Then start your Hunchentoot instance with something like:
(start (make-instance 'debuggable-acceptor :port whatever))
-Peter
>
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel
>
--
Peter Seibel
http://www.codersatwork.com/
http://www.gigamonkeys.com/blog/
More information about the Tbnl-devel
mailing list