Skip to content

Commit

Permalink
test: remove unreachable code
Browse files Browse the repository at this point in the history
There is no way a line can be called after throwing an exception.

PR-URL: #2289
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Brendan Ashworth <[email protected]>
  • Loading branch information
targos authored and rvagg committed Aug 21, 2015
1 parent 3579f3a commit e714b56
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 16 deletions.
4 changes: 0 additions & 4 deletions test/message/throw_custom_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
var common = require('../common');
var assert = require('assert');

console.error('before');

// custom error throwing
throw ({ name: 'MyCustomError', message: 'This is a custom message' });

console.error('after');
3 changes: 1 addition & 2 deletions test/message/throw_custom_error.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
before
*test*message*throw_custom_error.js:8
*test*message*throw_custom_error.js:6
throw ({ name: 'MyCustomError', message: 'This is a custom message' });
^
MyCustomError: This is a custom message
4 changes: 0 additions & 4 deletions test/message/throw_non_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
var common = require('../common');
var assert = require('assert');

console.error('before');

// custom error throwing
throw ({ foo: 'bar' });

console.error('after');
3 changes: 1 addition & 2 deletions test/message/throw_non_error.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
before
*test*message*throw_non_error.js:8
*test*message*throw_non_error.js:6
throw ({ foo: 'bar' });
^
[object Object]
1 change: 0 additions & 1 deletion test/parallel/test-domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ expectCaught++;
// as a callback instead.
function fn(er) {
throw new Error('This function should never be called!');
process.exit(1);
}

var bound = d.intercept(fn);
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-file-write-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ file
})
.on('error', function(err) {
throw err;
console.error('error!', err.stack);
})
.on('drain', function() {
console.error('drain!', callbacks.drain);
Expand Down
1 change: 0 additions & 1 deletion test/parallel/test-http-content-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var server = http.createServer(function(req, res) {
break;
default:
throw new Error('Unreachable');
break;
}

receivedRequests++;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-listen-fd-detached-inherit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function test() {
// Then output the child's pid, and immediately exit.
function parent() {
var server = net.createServer(function(conn) {
throw new Error('Should not see connections on parent');
conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n');
throw new Error('Should not see connections on parent');
}).listen(PORT, function() {
console.error('server listening on %d', PORT);

Expand Down

0 comments on commit e714b56

Please sign in to comment.