Skip to content

Commit

Permalink
doc: clarify error handling in net.createServer
Browse files Browse the repository at this point in the history
Remove indications that an error argument is sent to the `listen()` callback.

Fixes: #5345
PR-URL: #5353
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information
dirceu authored and Myles Borins committed Mar 1, 2016
1 parent 13b9b12 commit 1d97ce0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions doc/api/net.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ Example:
```js
var server = net.createServer((socket) => {
socket.end('goodbye\n');
}).on('error', (err) => {
// handle errors here
throw err;
});

// grab a random port.
server.listen((err) => {
if (err) throw err;
server.listen(() => {
address = server.address();
console.log('opened server on %j', address);
});
Expand Down Expand Up @@ -655,9 +657,10 @@ const server = net.createServer((c) => {
c.write('hello\r\n');
c.pipe(c);
});
server.listen(8124, (err) => {
// 'listening' listener
if (err) throw err;
server.on('error', (err) => {
throw err;
});
server.listen(8124, () => {
console.log('server bound');
});
```
Expand All @@ -672,9 +675,8 @@ To listen on the socket `/tmp/echo.sock` the third line from the last would
just be changed to

```js
server.listen('/tmp/echo.sock', (err) => {
// 'listening' listener
if (err) throw err;
server.listen('/tmp/echo.sock', () => {
console.log('server bound');
});
```

Expand Down

0 comments on commit 1d97ce0

Please sign in to comment.