Skip to content

Commit

Permalink
Check err.code instead of err.errno for 0.5.x compat.
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Nov 4, 2011
1 parent 1a59c6b commit e58f0d3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions indexer.js
Expand Up @@ -3,8 +3,6 @@ var Fs = require('fs'),
Url = require('url'),
getMime = require('simple-mime')("application/octet-stream");

var ENOENT = process.ENOENT || require('constants').ENOENT;

module.exports = function setup(mount, root, showHidden) {

return function handle(req, res, next) {
Expand All @@ -17,7 +15,7 @@ module.exports = function setup(mount, root, showHidden) {
if (path[path.length - 1] === '/') { path = path.substr(0, path.length - 1); }
Fs.stat(path, function (err, stat) {
if (err) {
if (err.errno === ENOENT) { return next(); }
if (err.code === 'ENOENT') { return next(); }
return next(err);
}
if (!stat.isDirectory()) {
Expand Down
1 change: 1 addition & 0 deletions share.js
Expand Up @@ -16,6 +16,7 @@ function listen() {
Http.createServer(handler).listen(PORT);
console.log("Serving %s at http://localhost:%s/", path, PORT);
} catch (err) {
// this is probably broken in node 0.5.x. Should check err.code instead.
if (err.errno !== 98) { throw err; }
PORT++;
listen();
Expand Down
3 changes: 1 addition & 2 deletions static.js
Expand Up @@ -4,7 +4,6 @@ var Path = require('path'),
getMime = require('simple-mime')("application/octet-stream");

// Compat stuff to make this work on the v0.2.x and v0.3.x branches of node
var ENOENT = process.ENOENT || require('constants').ENOENT;
var StreamProto = require('net').Stream.prototype.__proto__;
if (!StreamProto.hasOwnProperty('pipe')) {
var sys = require('sys');
Expand Down Expand Up @@ -38,7 +37,7 @@ module.exports = function setup(mount, root, index) {
}
function onStat(err, stat) {
if (err) {
if (err.errno === ENOENT) { return next(); }
if (err.code === 'ENOENT') { return next(); }
return next(err);
}
if (index && stat.isDirectory()) {
Expand Down

0 comments on commit e58f0d3

Please sign in to comment.