Stack traces in Clojure prettier? Almost. It’s Ring

Clojure stack traces got pretty-printed or is it Ring? I believe it’s Ring’s ring.middleware.stacktrace which is described as “Catch exceptions and render web and log stacktraces for debugging.”

I’m developing my first web application in Clojure and I’ve just been pleasantly surprised having seen it (= the nicely-formatted stack trace, but not the stack trace itself). I just followed Interactive Development of Ring and without a handler the following exception was thrown and obviously expected.

jacek:~/oss/librarian-clojure
$ lein ring server
2012-01-28 21:12:09.469:INFO::Logging to STDERR via org.mortbay.log.StdErrLogStarted server on port 3000

2012-01-28 21:12:09.483:INFO::jetty-6.1.25
2012-01-28 21:12:09.526:INFO::Started SocketConnector@0.0.0.0:3000
Exception: java.lang.NullPointerException: null
                     stacktrace.clj:15 ring.middleware.stacktrace/wrap-stacktrace-log[fn]
                     stacktrace.clj:79 ring.middleware.stacktrace/wrap-stacktrace-web[fn]
                         reload.clj:18 ring.middleware.reload/wrap-reload[fn]
                          jetty.clj:16 ring.adapter.jetty/proxy-handler[fn]
                      (Unknown Source) ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle
               HandlerWrapper.java:152 org.mortbay.jetty.handler.HandlerWrapper.handle
                       Server.java:326 org.mortbay.jetty.Server.handle
               HttpConnection.java:542 org.mortbay.jetty.HttpConnection.handleRequest
               HttpConnection.java:926 org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete
                   HttpParser.java:549 org.mortbay.jetty.HttpParser.parseNext
                   HttpParser.java:212 org.mortbay.jetty.HttpParser.parseAvailable
               HttpConnection.java:404 org.mortbay.jetty.HttpConnection.handle
              SocketConnector.java:228 org.mortbay.jetty.bio.SocketConnector$Connection.run
             QueuedThreadPool.java:582 org.mortbay.thread.QueuedThreadPool$PoolThread.run

Exception: java.lang.NullPointerException: null
                     stacktrace.clj:15 ring.middleware.stacktrace/wrap-stacktrace-log[fn]
                     stacktrace.clj:79 ring.middleware.stacktrace/wrap-stacktrace-web[fn]
                         reload.clj:18 ring.middleware.reload/wrap-reload[fn]
                          jetty.clj:16 ring.adapter.jetty/proxy-handler[fn]
                      (Unknown Source) ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle
               HandlerWrapper.java:152 org.mortbay.jetty.handler.HandlerWrapper.handle
                       Server.java:326 org.mortbay.jetty.Server.handle
               HttpConnection.java:542 org.mortbay.jetty.HttpConnection.handleRequest
               HttpConnection.java:926 org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete
                   HttpParser.java:549 org.mortbay.jetty.HttpParser.parseNext
                   HttpParser.java:212 org.mortbay.jetty.HttpParser.parseAvailable
               HttpConnection.java:404 org.mortbay.jetty.HttpConnection.handle
              SocketConnector.java:228 org.mortbay.jetty.bio.SocketConnector$Connection.run
             QueuedThreadPool.java:582 org.mortbay.thread.QueuedThreadPool$PoolThread.run

The stack trace in the browser was pretty, too.

If stack traces were any indication of what’s ahead, I can’t wait till I taste the other goodies of Clojure, Ring, Compojure, ClojureScript One for web development.

Be Sociable, Share!
This entry was posted in Languages.

Leave a Reply

%d bloggers like this: