| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,9 @@ | |||
| 1 | 1 | "use strict"; | |
| 2 | 2 | export default function () { | |
| 3 | 3 | return function errorHandling(err, req, res, next) { | |
| 4 | - console.error(err.stack); | ||
| 5 | - res.status(500).send(err.message); | ||
| 4 | + res.writeHead(404); | ||
| 5 | + res.write(err.message); | ||
| 6 | + res.end(); | ||
| 6 | 7 | next(); | |
| 7 | 8 | }; | |
| 8 | 9 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,20 +14,20 @@ describe("connect", function () { | |||
| 14 | 14 | describe("errorHandler", function () { | |
| 15 | 15 | beforeEach(function (done) { | |
| 16 | 16 | let app = connect(); | |
| 17 | - app.use(errorHandler()); | ||
| 18 | 17 | app.use((req, res, next) => { | |
| 19 | 18 | next(new Error("wrong")); | |
| 20 | 19 | }); | |
| 20 | + app.use(errorHandler()); | ||
| 21 | 21 | server = http.createServer(app).listen(3000, done); | |
| 22 | 22 | }); | |
| 23 | 23 | afterEach(function () { | |
| 24 | 24 | server && server.close(); | |
| 25 | 25 | }); | |
| 26 | - it("should return 500 status response", function () { | ||
| 26 | + it("should return 404 status response", function () { | ||
| 27 | 27 | return fetch("http://localhost:3000") | |
| 28 | 28 | .then(res => res.status) | |
| 29 | 29 | .then(status => { | |
| 30 | - assert(status, 500); | ||
| 30 | + assert(status, 404); | ||
| 31 | 31 | }); | |
| 32 | 32 | }); | |
| 33 | 33 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments