Skip to content

Commit

Permalink
chore(guide): fulfil error handler and trailers (#4087)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eomm committed Jun 25, 2022
1 parent 6405c2d commit 6a4b34c
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion docs/Guides/Migration-Guide-V4.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,39 @@ work after upgrading.

## Breaking Changes

### Deprecation of `app.use()`
### Error handling composition ([#3261](https://github.com/fastify/fastify/pull/3261))

When an error is thrown in a async error handler function,
the upper-level error handler is executed if set.
If there is not a upper-level error handler, the default will
be executed as it was previously.

```
import Fastify from 'fastify'
const fastify = Fastify()
fastify.register(async fastify => {
fastify.setErrorHandler(async err => {
console.log(err.message) // 'kaboom'
throw new Error('caught')
})
fastify.get('/encapsulated', async () => {
throw new Error('kaboom')
})
})
fastify.setErrorHandler(async err => {
console.log(err.message) // 'caught'
throw new Error('wrapped')
})
const res = await fastify.inject('/encapsulated')
console.log(res.json().message) // 'wrapped'
```

### Deprecation of `app.use()` ([#3506](https://github.com/fastify/fastify/pull/3506))

Starting this version of Fastify, we have deprecated the use of `app.use()`. We
have decided not to support the use of middlewares. Both
Expand Down Expand Up @@ -70,3 +102,10 @@ properties: {
}
}
```

### Add `reply.trailers` methods ([#3794](https://github.com/fastify/fastify/pull/3794))

Fastify now supports the [HTTP Trailer] response headers.


[HTTP Trailer]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer

0 comments on commit 6a4b34c

Please sign in to comment.