diff options
| author | Adam Soltys <[email protected]> | 2023-03-02 17:16:11 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2023-03-05 00:19:09 -0800 |
| commit | 2afb528326ea27c7073938d64aab994ea677bdc7 (patch) | |
| tree | d63de49fde614244f7a65823aeb73dca25b8ea10 /lib | |
| parent | fdc67f54a1f630bc1da25fcbf989743f42cda974 (diff) | |
| download | coinos-server-2afb528326ea27c7073938d64aab994ea677bdc7.tar.gz coinos-server-2afb528326ea27c7073938d64aab994ea677bdc7.zip | |
error handlers
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/app.js | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -37,4 +37,19 @@ app.register(fastifyStatic, { app.register(fastifyWs); app.register(socketServer); +app.setErrorHandler((error, request, reply) => { + if (error instanceof fastify.errorCodes.FST_ERR_BAD_STATUS_CODE) { + reply.status(500).send({ ok: false }) + } else { + reply.send(error) + } +}) + +app.setNotFoundHandler((request, reply) => { + reply + .code(404) + .type("text/html") + .send("Not Found"); +}); + export default app; |
