aboekhoff/congomongo — Issue #42: Ugly error when database not connected
Author: benekastah
Created: 2011-12-08 07:56:31+00:00
State: open

I was trying to get things saving to mongo for perhaps a week (a week of spare time, that is). The problem ended up being simply that I hadn't initiated a connection to the database. Instead of getting a descriptive error, I got a `NullPointerException`. A prettier error would probably save a lot of folks a lot of time.

My error message:

```
java.lang.NullPointerException
at somnium.congomongo$insert_BANG_.doInvoke(congomongo.clj:233)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at bayou.models.user$insert_BANG_.invoke(user.clj:16)
at bayou.views.api.user$POSTurl$fn__175.invoke(user.clj:16)
at bayou.lib.api_helpers$respond.invoke(api_helpers.clj:12)
at bayou.views.api.user$POSTurl.invoke(user.clj:16)
at bayou.views.api.user$eval182$fn__183.invoke(user.clj:10)
at compojure.core$if_route$fn__274.invoke(core.clj:39)
at compojure.core$if_method$fn__267.invoke(core.clj:24)
at compojure.core$routing$fn__289.invoke(core.clj:98)
at clojure.core$some.invoke(core.clj:2388)
at compojure.core$routing.doInvoke(core.clj:98)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:602)
at compojure.core$routes$fn__293.invoke(core.clj:103)
at noir.server.handler$init_routes$fn__1419.invoke(handler.clj:55)
at noir.request$wrap_request_map$fn__1356.invoke(request.clj:14)
at ring.middleware.keyword_params$wrap_keyword_params$fn__419.invoke(keyword_params.clj:21)
at ring.middleware.nested_params$wrap_nested_params$fn__456.invoke(nested_params.clj:64)
at ring.middleware.params$wrap_params$fn__396.invoke(params.clj:76)
at ring.middleware.multipart_params$wrap_multipart_params$fn__489.invoke(multipart_params.clj:102)
at ring.middleware.session$wrap_session$fn__644.invoke(session.clj:40)
at ring.middleware.cookies$wrap_cookies$fn__581.invoke(cookies.clj:132)
at noir.server.handler$wrap_base_url$fn__1410.invoke(handler.clj:38)
at noir.session$noir_session$fn__1370.invoke(session.clj:58)
at ring.middleware.session$wrap_session$fn__644.invoke(session.clj:40)
at ring.middleware.cookies$wrap_cookies$fn__581.invoke(cookies.clj:132)
at noir.cookies$noir_cookies$fn__1222.invoke(cookies.clj:66)
at ring.middleware.cookies$wrap_cookies$fn__581.invoke(cookies.clj:132)
at noir.validation$wrap_noir_validation$fn__1397.invoke(validation.clj:88)
at noir.statuses$wrap_status_pages$fn__1318.invoke(statuses.clj:23)
at ring.middleware.reload_modified$wrap_reload_modified$fn__781.invoke(reload_modified.clj:15)
at noir.server.handler$wrap_url_decode$fn__1406.invoke(handler.clj:27)
at noir.exception$wrap_exceptions$fn__1349.invoke(exception.clj:59)
at noir.options$wrap_options$fn__1312.invoke(options.clj:34)
at ring.adapter.jetty$proxy_handler$fn__713.invoke(jetty.clj:16)
at ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle(Unknown Source)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
```