That "development only" comment was leftover from a previous
implementation.. fixed that up.

Express knows this is an error handler middleware because it has 4
parameters:
http://expressjs.com/guide.html#error-handling

There is a more explicit "app.error" method, but that has been deprecated
in favor of the middleware function in more recent versions of express.


On Sun, Sep 22, 2013 at 2:47 PM, David Rueck <notifications@github.com>wrote:

> In app.js:
>
> >  // route registration
> >  require('./routes')(app, config.db);
> >
> >  // socket.io server logic
> >  require('./lib/poem-editing')(io, config.db);
> >
> > +// development only
> > +app.use(function(err, req, res, next) {
>
> Just a couple of questions on this one:
>
>    1. The comment says development only... what makes it work only in
>    development?
>    2. I don't understand why this is only getting triggered when an error
>    occurs. I assumed that anything you stick in the middleware would get
>    triggered on every request, but I tried it out and it's (correctly) only
>    getting triggered when there's an error. Is there something about the
>    callback definition or something that makes it work this way? It's working
>    how it should (as far as I can tell), I'm just trying to understand why. : )
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/jimguys/poemlab/pull/18/files#r6506382>
> .
>