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

No format control for simple-error #93

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 22 additions & 4 deletions src/woo.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,35 @@
:content-length (length body)))
(wev:write-socket-data socket body)))))))

(define-condition woo-error (simple-error) ())
(define-condition invalid-http-version (woo-error) ())
(define-condition woo-simple-error (simple-error)
((description :initarg :description)
(code :initarg :code
:initform nil))
(:report (lambda (condition stream)
(with-slots (description code) condition
(format stream
"~A~:[~;~:* (Code: ~A)~]"
description code)))))

(define-condition invalid-http-version (woo-simple-error)
())


(defun http-version-keyword (major minor)
(unless (= major 1)
(error 'invalid-http-version))
(print "Http major version component invalid")
;(error 'invalid-http-version :description "Major http version component invalid" :code 400)
nil
)

(case minor
(1 :HTTP/1.1)
(0 :HTTP/1.0)
(otherwise (error 'invalid-http-version))))
(otherwise
(print "Http minor version component invalid")
;(error 'invalid-http-version :description "Minor http version component invalid" :code 400)
nil
)))

(defun setup-parser (socket)
(let ((http (make-http-request))
Expand Down