1

I am having trouble with express Error handling. Here is my configuration for the server.

    server.use(express.static(__dirname + '/public'));
    server.use(server.router);
    server.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    server.use(express.bodyParser());

Then I try adding this line of code

server.error(function(err, req, res, next){
if (err instanceof NotFound) {
    res.render('404.jade');
} else {
    next(err);
}
});

Then in my console, I get this message,

Object function app(req, res){ app.handle(req, res); } has no method 'error'

what am I doing wrong? I cant get error handling to work.

1

1 Answer 1

3

What version of express are you using?

Because there is a new 3.x version (still in alpha stage) out that changed quite a lot of stuff, and things such as the error handling is changed

Check out the migration guide from 2.x to 3.x

The page is a work in progress, consider moving back to 2.x or waiting for a better 3.x documentation and migration guide

Sign up to request clarification or add additional context in comments.

5 Comments

Yeah it seems that 3.X was installed. Will Check a way to down grade. Will See if npm has functions for this. Thanks!
Just do: npm install [email protected]
Yeah, but it seems that 2.59 is not compatible with my version of node. I have node v0.7.2-pre installed. I was wondering if there was a way to downgrade this. Thanks Man.
no fix this in stalled a package called n, which handles binaries of node. Cool
yep, I know, I answered your other question ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.