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

Appearance settings

Commit f197012

Browse filesBrowse files
mcollinatargos
authored andcommitted
doc: add try/catch in http2 respondWithFile example
PR-URL: #38410 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 47626c5 commit f197012
Copy full SHA for f197012

File tree

Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Open diff view settings
Collapse file

‎doc/api/http2.md‎

Copy file name to clipboardExpand all lines: doc/api/http2.md
+11-4Lines changed: 11 additions & 4 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1669,10 +1669,17 @@ server.on('stream', (stream) => {
16691669
}
16701670

16711671
function onError(err) {
1672-
if (err.code === 'ENOENT') {
1673-
stream.respond({ ':status': 404 });
1674-
} else {
1675-
stream.respond({ ':status': 500 });
1672+
// stream.respond() can throw if the stream has been destroyed by
1673+
// the other side.
1674+
try {
1675+
if (err.code === 'ENOENT') {
1676+
stream.respond({ ':status': 404 });
1677+
} else {
1678+
stream.respond({ ':status': 500 });
1679+
}
1680+
} catch (err) {
1681+
// Perform actual error handling.
1682+
console.log(err);
16761683
}
16771684
stream.end();
16781685
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.