Thursday, January 29, 2009

Error Messages in the PLT Scheme Web Server

I've just committed what I hope is a very useful addition to the PLT Web Server.

Previously, if there was a problem with the syntax of the HTML code in your servlet, you would get an opaque error, such as:

You broke the contract (-> request response) on start; expected <response?>, given: (html (head ...

And you would have little clue what the problem with it was.

Now, the Web Server will reformat your response and annotate it will all of its problems, then display that back to you.

A sample is available online.

Notice that all the errors are highlighted in red and when you hover over them, an explanation is given.

If you would like to try at home, get the latest SVN and try out the following servlet:

#lang web-server/insta
(define (start req)
  `(html (head (title "Hey"))
         (body
          nbsp
          ; Error 1
          ()
          ; Error 2
          ("foo")
          ; Error 3
          #f
          ; Error 4
          (p . #f)
          ; Error 5
          (span ([href "#"] . #f) nbsp)
          ; Error 6
          (span ([href #f]) nbsp)
          ; Error 7
          (span ([#f "#"]) nbsp)
          ; Error 8
          (span ([href "#"] #f) nbsp))))

0 comments: