add bad-request printer
authorAndy Wingo <wingo@pobox.com>
Sun, 11 Mar 2012 09:57:05 +0000 (10:57 +0100)
committerAndy Wingo <wingo@pobox.com>
Thu, 22 Mar 2012 08:56:27 +0000 (09:56 +0100)
* module/web/request.scm (bad-request-printer): Add printer for these
  exceptions.

module/web/request.scm

index 8259887..40d4a66 100644 (file)
@@ -1,6 +1,6 @@
 ;;; HTTP request objects
 
-;; Copyright (C)  2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C)  2010, 2011, 2012 Free Software Foundation, Inc.
 
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
 (define (bad-request message . args)
   (throw 'bad-request message args))
 
+(define (bad-request-printer port key args default-printer)
+  (apply (case-lambda
+           ((msg args)
+            (display "Bad request: " port)
+            (apply format port msg args)
+            (newline port))
+           (_ (default-printer)))
+         args))
+
+(set-exception-printer! 'bad-request bad-request-printer)
+
 (define (non-negative-integer? n)
   (and (number? n) (>= n 0) (exact? n) (integer? n)))