Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcbfc8d7

Browse files
committed
fix(connect): correct errorHandler
1 parent783fd57 commitcbfc8d7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

‎src/connect/errorHandler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"use strict";
22
exportdefaultfunction(){
33
returnfunctionerrorHandling(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();
67
next();
78
};
89
}

‎test/connect/hello-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ describe("connect", function () {
1414
describe("errorHandler",function(){
1515
beforeEach(function(done){
1616
letapp=connect();
17-
app.use(errorHandler());
1817
app.use((req,res,next)=>{
1918
next(newError("wrong"));
2019
});
20+
app.use(errorHandler());
2121
server=http.createServer(app).listen(3000,done);
2222
});
2323
afterEach(function(){
2424
server&&server.close();
2525
});
26-
it("should return500 status response",function(){
26+
it("should return404 status response",function(){
2727
returnfetch("http://localhost:3000")
2828
.then(res=>res.status)
2929
.then(status=>{
30-
assert(status,500);
30+
assert(status,404);
3131
});
3232
});
3333

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp