Created
January 5, 2022 10:19
-
-
Save delvedor/709f4d71527be93b7450a4ced87aba16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment