From aaaa0eef9cfdb426f0b0fb4423fc25b655b722a4 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 11 Mar 2012 10:24:08 +0100 Subject: [PATCH] add exception printers for bad-header, bad-header-component * module/web/http.scm (bad-header-component): Throw 'bad-header-component instead of 'bad-header. (bad-header-printer, bad-header-component-printer): Add exception printers. --- module/web/http.scm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/module/web/http.scm b/module/web/http.scm index 10c5fcf77..80f972ba5 100644 --- a/module/web/http.scm +++ b/module/web/http.scm @@ -240,7 +240,22 @@ ordered alist." (define (bad-header sym val) (throw 'bad-header sym val)) (define (bad-header-component sym val) - (throw 'bad-header sym val)) + (throw 'bad-header-component sym val)) + +(define (bad-header-printer port key args default-printer) + (apply (case-lambda + ((sym val) + (format port "Bad ~a header: ~a\n" (header->string sym) val)) + (_ (default-printer))) + args)) +(define (bad-header-component-printer port key args default-printer) + (apply (case-lambda + ((sym val) + (format port "Bad ~a header component: ~a\n" sym val)) + (_ (default-printer))) + args)) +(set-exception-printer! 'bad-header bad-header-printer) +(set-exception-printer! 'bad-header-component bad-header-component-printer) (define (parse-opaque-string str) str)