| 72 | } |
| 73 | |
| 74 | const handler = (request, reply) => { |
| 75 | if (request.body.id === '400') { |
| 76 | return reply.status(400).send({ |
| 77 | statusCode: 400, |
| 78 | error: 'Bad Request', |
| 79 | message: 'Custom message', |
| 80 | extra: 'This should not be in the response' |
| 81 | }) |
| 82 | } |
| 83 | |
| 84 | if (request.body.id === '404') { |
| 85 | return reply.status(404).send({ |
| 86 | statusCode: 404, |
| 87 | error: 'Not Found', |
| 88 | message: 'Custom Not Found', |
| 89 | extra: 'This should not be in the response' |
| 90 | }) |
| 91 | } |
| 92 | |
| 93 | if (request.body.id === '500') { |
| 94 | reply.status(500).send({ |
| 95 | statusCode: 500, |
| 96 | error: 'Internal Server Error', |
| 97 | message: 'Custom Internal Server Error', |
| 98 | extra: 'This should not be in the response' |
| 99 | }) |
| 100 | } |
| 101 | |
| 102 | reply.send({ |
| 103 | id: request.body.id, |
| 104 | extra: 'This should not be in the response' |
| 105 | }) |
| 106 | } |
| 107 | |
| 108 | test('serialize the response for a Bad Request error, as defined on the schema', async t => { |
| 109 | t.plan(2) |