We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6e046d commit 252975bCopy full SHA for 252975b
utils/error.js
@@ -0,0 +1,26 @@
1
+'use strict'
2
+
3
+function createNotFoundError(message) {
4
+ const error = new Error(message)
5
+ error.name = 'NotFoundError'
6
+ error.statusCode = 404
7
+ return error
8
+}
9
10
+async function handleReadNoteError(error, request, reply) {
11
+ if (error.name === 'NotFoundError') {
12
+ const { id } = request.params
13
+ request.log.info(`Note not found for ID: ${id} and User ID: ${request.user.id}`)
14
+ await reply.status(404).send({
15
+ statusCode: 404,
16
+ error: 'Not Found',
17
+ message: error.message,
18
+ requestId: request.id,
19
+ })
20
+ } else {
21
+ request.log.error('Error reading note:', error)
22
+ await reply.send(error)
23
+ }
24
25
26
+module.exports = { createNotFoundError, handleReadNoteError }
0 commit comments