How to catch a nodejs connect static 404 error?

I use nodeJS and senchalab's connect middleware (not express!!). I need to catch the static errors (like 404). How do i get these? I tried to check the source, but i could not find a way to pass an error-handler to connect.static.

here is a gist of the general structure i (have to) use:

https://gist.github.com/2397415

Based on your routes:

router.routes['/'] = 'my page';
router.routes['/404'] = '404 test';

I think you meant this:

connect()
  .use(connect.static(__dirname + '/public'))
  .use(function(req, res, next){
    switch (req.url) {
      case '/404':
        var body = '404 test';
        res.statusCode = 404;
        res.setHeader('Content-Length', body.length);
        res.end(body);
        break;
      default:
        var body = 'my page';
        res.setHeader('Content-Length', body.length);
        res.end(body);
    }
  })
  .listen(3001);

Also I want to add that in old connect version 1.x you can use 'connect.router', but in 2.x version it was removed and moved to express. If you need useful routing system, use express:

Connect was never meant to be used directly, it exists to support frameworks like Express

You could add a catch-all routes after static and all your routes:

app.get('*', function(req, res){
  //respond with 404 page or something.
})

It will catch all unmatched GET requests.