From ae63d87225cc63b4485fa00a3e5e30244cbc5333 Mon Sep 17 00:00:00 2001 From: Dustin Popp Date: Wed, 4 Dec 2024 09:39:40 -0600 Subject: [PATCH] chore: add code example Co-authored-by: M. Heide <66078329+heidemn-faro@users.noreply.github.com> --- en/guide/migrating-5.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/en/guide/migrating-5.md b/en/guide/migrating-5.md index 87de5c59ce..ab9155cec0 100755 --- a/en/guide/migrating-5.md +++ b/en/guide/migrating-5.md @@ -163,6 +163,16 @@ The `express.urlencoded` method makes the `extended` option `false` by default.

app.listen

In Express 5, the `app.listen` method will invoke the user-provided callback function (if provided) when the server receives an error event. In Express 4, such errors would be thrown. This change shifts error-handling responsibility to the callback function in Express 5. +Example: + +```js +const server = app.listen(8080, '0.0.0.0', (error) => { + if (error) { + throw error; // e.g. EADDRINUSE + } + console.log('Listening on ' + JSON.stringify(server.address())); +}); +```

app.router