hi all
i make my website with hunchentoot. it works very fine. My database backend could throw some conditions (db-connect-error, db-...-error, ...), and i would like to print the error message.
i have modify the default error handler like this :
(defun handle-error (arg) "Modify the Hunchentoot error dispatcher." ;;(declare (ignore arg)) (make-web-page #p"error.html" (list :message (format nil "~A" arg))))
and the HTML template :
<div id="title"> Error </div> <div id="error"> <b> Internal error : </b> <br> <!-- TMPL_VAR message --> </div>
in the final web page i see :
<div id="title"> Error </div> Internal error : 500
i would like to print a customized error message. it is possible ? i try to modify my code like this :
(handler-case (progn ...) (db-connect-error (cond) (setf (hunchentoot:session-value 'error-msg) cond) (hunchentoot:redirect "/test-lam/index")) ...)
he index-handler which print the error message but it doesn't works. The customize error handler catch the exception before
someone knows how could i make this ? thanks for any help.
On Mon, 26 Feb 2007 20:11:27 +0100, Nicolas Lamirault lam@tuxfamily.org wrote:
i would like to print a customized error message. it is possible ?
Sure.
i try to modify my code like this :
(handler-case (progn ...) (db-connect-error (cond) (setf (hunchentoot:session-value 'error-msg) cond) (hunchentoot:redirect "/test-lam/index")) ...)
he index-handler which print the error message but it doesn't works. The customize error handler catch the exception before
From your example it's impossible to see where the problem is. What's
in the "..." part? Are you sure the error happens in there? Are you sure it's of type DB-CONNECT-ERROR?
hello, thanks for reply ...
Edi Weitz edi@agharta.de writes:
On Mon, 26 Feb 2007 20:11:27 +0100, Nicolas Lamirault lam@tuxfamily.org wrote:
i would like to print a customized error message. it is possible ?
Sure.
i try to modify my code like this :
(handler-case (progn ...) (db-connect-error (cond) (setf (hunchentoot:session-value 'error-msg) cond) (hunchentoot:redirect "/test-lam/index")) ...)
he index-handler which print the error message but it doesn't works. The customize error handler catch the exception before
From your example it's impossible to see where the problem is. What's
in the "..." part? Are you sure the error happens in there? Are you sure it's of type DB-CONNECT-ERROR?
oh thanks ! i'm writing a mail which explain my problem, with the backtrace of hunchentoot, and i find my problem !
another question : the
(handler-case (progn ...) (db-connect-error (cond) (setf (hunchentoot:session-value 'error-msg) cond) (hunchentoot:redirect "/test-lam/index")) ...)
works fine. But how the error dispatcher could print the error message to the template ?
i could make this :
(package-type-unknown-error (condition) (hunchentoot:log-message :warn "Clappa system : ~A" condition) (setf (hunchentoot:session-value 'error-msg) (clappa-system:package-type condition)) (hunchentoot:redirect "/clappa/error"))
and creates a dispatcher "/clappa/error" -> error-dispatcher. But how use the error dispatcher (with one arg) :
(defun handle-error (arg) "Modify the Hunchentoot error dispatcher." (declare (ignore arg)) (make-web-page #p"error.html" (list :message (format nil "~A" (hunchentoot:session-value 'error-msg)))))
?
Thanks for your help ...
On Mon, 26 Feb 2007 22:41:10 +0100, Nicolas Lamirault lam@tuxfamily.org wrote:
i'm writing a mail which explain my problem, with the backtrace of hunchentoot, and i find my problem !
Yes, that has happened to me a few times as well. It's always a good idea to try to create a bug report or question as detailed as possible... :)
But how the error dispatcher could print the error message to the template ?
i could make this :
(package-type-unknown-error (condition) (hunchentoot:log-message :warn "Clappa system : ~A" condition) (setf (hunchentoot:session-value 'error-msg) (clappa-system:package-type condition)) (hunchentoot:redirect "/clappa/error"))
and creates a dispatcher "/clappa/error" -> error-dispatcher.
Why don't you just have a handler (instead of a dispatcher) which handles the "/clappa/error" URI (and looks at the session value to generate a message)? You could also, BTW, store the condition itself in the session.
Edi Weitz edi@agharta.de writes:
On Mon, 26 Feb 2007 22:41:10 +0100, Nicolas Lamirault lam@tuxfamily.org wrote:
i'm writing a mail which explain my problem, with the backtrace of hunchentoot, and i find my problem !
Yes, that has happened to me a few times as well. It's always a good idea to try to create a bug report or question as detailed as possible... :)
yes :)
But how the error dispatcher could print the error message to the template ?
i could make this :
(package-type-unknown-error (condition) (hunchentoot:log-message :warn "Clappa system : ~A" condition) (setf (hunchentoot:session-value 'error-msg) (clappa-system:package-type condition)) (hunchentoot:redirect "/clappa/error"))
and creates a dispatcher "/clappa/error" -> error-dispatcher.
Why don't you just have a handler (instead of a dispatcher) which handles the "/clappa/error" URI (and looks at the session value to generate a message)? You could also, BTW, store the condition itself in the session.
yes ... i'm trying to implements this ...
thanks for your help and Hunchentoot ...
tbnl-devel site list tbnl-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/tbnl-devel