Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't wrap the handler body in with-mapped-conditions #186

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions acceptor.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ This is supposed to force a check of ACCEPTOR-SHUTDOWN-P."
;; this around method is used for error handling
;; note that this method also binds *ACCEPTOR*
(with-conditions-caught-and-logged ()
(with-mapped-conditions ()
(call-next-method))))
(call-next-method)))

(defun do-with-acceptor-request-count-incremented (*acceptor* function)
(with-lock-held ((acceptor-shutdown-lock *acceptor*))
Expand Down
69 changes: 35 additions & 34 deletions request.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -223,35 +223,36 @@ slot values are computed in this :AFTER method."
*headers-sent*
(*request* request))
(unwind-protect
(with-mapped-conditions ()
(labels
((report-error-to-client (error &optional backtrace)
(when *log-lisp-errors-p*
(log-message* *lisp-errors-log-level* "~A~@[~%~A~]" error (when *log-lisp-backtraces-p*
backtrace)))
(start-output +http-internal-server-error+
(acceptor-status-message *acceptor*
+http-internal-server-error+
:error (princ-to-string error)
:backtrace (princ-to-string backtrace)))))
(multiple-value-bind (contents error backtrace)
;; skip dispatch if bad request
(when (eql (return-code *reply*) +http-ok+)
(catch 'handler-done
(handle-request *acceptor* *request*)))
(when error
;; error occurred in request handler
(report-error-to-client error backtrace))
(unless *headers-sent*
(handler-case
(with-debugger
(start-output (return-code *reply*)
(or contents
(acceptor-status-message *acceptor*
(return-code *reply*)))))
(error (e)
;; error occurred while writing to the client. attempt to report.
(report-error-to-client e)))))))
(labels
((report-error-to-client (error &optional backtrace)
(when *log-lisp-errors-p*
(log-message* *lisp-errors-log-level* "~A~@[~%~A~]" error (when *log-lisp-backtraces-p*
backtrace)))
(start-output +http-internal-server-error+
(acceptor-status-message *acceptor*
+http-internal-server-error+
:error (princ-to-string error)
:backtrace (princ-to-string backtrace)))))
(multiple-value-bind (contents error backtrace)
;; skip dispatch if bad request
(when (eql (return-code *reply*) +http-ok+)
(catch 'handler-done
(handle-request *acceptor* *request*)))
(when error
;; error occurred in request handler
(with-mapped-conditions ()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I brought back the with-mapped-conditions here...

(report-error-to-client error backtrace)))
(unless *headers-sent*
(with-mapped-conditions ()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and here

(handler-case
(with-debugger
(start-output (return-code *reply*)
(or contents
(acceptor-status-message *acceptor*
(return-code *reply*)))))
(error (e)
;; error occurred while writing to the client. attempt to report.
(report-error-to-client e)))))))
(dolist (path *tmp-files*)
(when (and (pathnamep path) (probe-file path))
;; the handler may have chosen to (re)move the uploaded
Expand All @@ -271,8 +272,8 @@ alist or NIL if there was no data or the data could not be parsed."
(let* ((content-length (header-in :content-length request))
(content-stream (make-flexi-stream (content-stream request)
:external-format +latin-1+
:bound (if content-length
(parse-integer content-length
:bound (if content-length
(parse-integer content-length
:junk-allowed t)))))
(prog1
(parse-rfc2388-form-data content-stream (header-in :content-type request) external-format)
Expand Down Expand Up @@ -326,8 +327,8 @@ unknown character set ~A in request content type."
external-format))
((and (string-equal type "multipart")
(string-equal subtype "form-data")
(if content-length
(plusp (parse-integer content-length
(if content-length
(plusp (parse-integer content-length
:junk-allowed t))
t))
(prog1 (parse-multipart-form-data request external-format)
Expand All @@ -350,7 +351,7 @@ during the request."
(setf (slot-value request 'get-parameters)
(form-url-encoded-list-to-alist (split "&" (query-string request)) external-format))
(values))

(defun script-name* (&optional (request *request*))
"Returns the file name of the REQUEST object REQUEST. That's the
requested URI without the query string \(i.e the GET parameters)."
Expand Down