Skip to content
This repository

Call 'next()' on ENOENT errors #12

Closed
wants to merge 1 commit into from

2 participants

Nathan Rajlich Tim Caswell
Nathan Rajlich

Hey Tim, I'm just trying to clean up the extraneous error message that get printed to my server's stderr.

When a Googlebot tries for a "robot.txt", Wheat will call next(err) instead of just next(), resulting in this:
Error: git --git-dir=/home/nrajlich/node-http-server/tootallnate.net/blog.git show dbc2ec4:articles/robots.txt
fatal: ambiguous argument 'dbc2ec41609583ce92243936415a772966570ed1:articles/robots.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

    at ChildProcess.<anonymous> (/usr/local/lib/node/.npm/git-fs/0.0.4/package/lib/git-fs.js:176:16)
    at ChildProcess.emit (events:33:26)
    at Stream.<anonymous> (child_process:131:12)
    at Stream.emit (events:26:26)
    at Array.0 (net:987:12)
    at EventEmitter._tickCallback (node.js:53:20)
    at node.js:764:9

This fixes that, and also goes hand-in-hand with the pull request for git-fs I'm about to send to you.

Nathan Rajlich Pass through to the next 'connect' layer on an ENOENT error (i.e. req…
…uested file does not exist).

This matches the behavior of the 'staticProvider' middleware in 'connect', and will also prevent unnecessary errors being spewed to the server's stderr, when it should really only respond with a 404.
f16848f
Tim Caswell
Owner

Got it! thanks.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 22, 2010
Nathan Rajlich Pass through to the next 'connect' layer on an ENOENT error (i.e. req…
…uested file does not exist).

This matches the behavior of the 'staticProvider' middleware in 'connect', and will also prevent unnecessary errors being spewed to the server's stderr, when it should really only respond with a 404.
f16848f
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  lib/wheat.js
5  lib/wheat.js
@@ -36,8 +36,9 @@ function addRoute(regex, renderer) {
36 36
 function handleRoute(req, res, next, renderer, match) {
37 37
   function callback(err, data) {
38 38
     if (err) {
39  
-      next(err);
40  
-      return;
  39
+      return err.errno === process.ENOENT
  40
+        ? next()
  41
+        : next(err);
41 42
     }
42 43
     res.writeHead(200, data.headers);
43 44
     res.end(data.buffer);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.