Skip to content

Commit e714b56

Browse files
targosrvagg
authored andcommitted
test: remove unreachable code
There is no way a line can be called after throwing an exception. PR-URL: #2289 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
1 parent 3579f3a commit e714b56

8 files changed

+3
-16
lines changed

test/message/throw_custom_error.js

-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
var common = require('../common');
33
var assert = require('assert');
44

5-
console.error('before');
6-
75
// custom error throwing
86
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
9-
10-
console.error('after');

test/message/throw_custom_error.out

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
before
2-
*test*message*throw_custom_error.js:8
1+
*test*message*throw_custom_error.js:6
32
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
43
^
54
MyCustomError: This is a custom message

test/message/throw_non_error.js

-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
var common = require('../common');
33
var assert = require('assert');
44

5-
console.error('before');
6-
75
// custom error throwing
86
throw ({ foo: 'bar' });
9-
10-
console.error('after');

test/message/throw_non_error.out

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
before
2-
*test*message*throw_non_error.js:8
1+
*test*message*throw_non_error.js:6
32
throw ({ foo: 'bar' });
43
^
54
[object Object]

test/parallel/test-domain.js

-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ expectCaught++;
163163
// as a callback instead.
164164
function fn(er) {
165165
throw new Error('This function should never be called!');
166-
process.exit(1);
167166
}
168167

169168
var bound = d.intercept(fn);

test/parallel/test-file-write-stream.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ file
2626
})
2727
.on('error', function(err) {
2828
throw err;
29-
console.error('error!', err.stack);
3029
})
3130
.on('drain', function() {
3231
console.error('drain!', callbacks.drain);

test/parallel/test-http-content-length.js

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ var server = http.createServer(function(req, res) {
4040
break;
4141
default:
4242
throw new Error('Unreachable');
43-
break;
4443
}
4544

4645
receivedRequests++;

test/parallel/test-listen-fd-detached-inherit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function test() {
6464
// Then output the child's pid, and immediately exit.
6565
function parent() {
6666
var server = net.createServer(function(conn) {
67-
throw new Error('Should not see connections on parent');
6867
conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n');
68+
throw new Error('Should not see connections on parent');
6969
}).listen(PORT, function() {
7070
console.error('server listening on %d', PORT);
7171

0 commit comments

Comments
 (0)