Error 500 on validation 2
Prerequisites
We do our best to reply to all the issues on time. If you will follow the given guidelines, the turn around time will be faster.
- Lots of raised issues are directly not bugs but instead are design decisions taken by us.
- Make use of our GH discussions, or discord server, if you are not sure that you are reporting a bug.
- Ensure the issue isn't already reported.
- Ensure you are reporting the bug in the correct repo.
Delete the above section and the instructions in the sections below before submitting
Package version
^5.8.0 core.
Node.js and npm version
v14.20.1 and 6.14.17
Sample Code (to reproduce the issue)
import Logger from '@ioc:Adonis/Core/Logger'
import HttpExceptionHandler from '@ioc:Adonis/Core/HttpExceptionHandler'
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
export default class ExceptionHandler extends HttpExceptionHandler {
protected disableStatusPagesInDevelopment = true
constructor() {
super(Logger)
}
public async handle(error: any, ctx: HttpContextContract) {
console.log('test')
if (error.code === 'E_VALIDATION_FAILURE') {
return ctx.response.status(422).send(error.messages)
}
return super.handle(error, ctx)
}
}
import Route from '@ioc:Adonis/Core/Route'
import { schema } from '@ioc:Adonis/Core/Validator'
Route.post('posts', async ({ request }) => {
/**
* Schema definition
*/
const newPostSchema = schema.create({
body: schema.string(),
})
/**
* Validate request body against the schema
*/
const payload = await request.validate({ schema: newPostSchema })
})
BONUS (a sample repo to reproduce the issue)

I don't know if this is an error when validating or configuring the expection because even with it configured the validation continues to return as an error 500, making it impossible to create tests with the wrong message body.
**if (error.code === 'E_VALIDATION_FAILURE') {
return ctx.response.status(422).send(error.messages)
}**
based on documentation, it was for validation errors to return status 422 but keeps returning 500.
#158
The route you have shared is for path /posts, but you are making an HTTP request to /sendmessage. To avoid further back and forth, I recommend reproducing this issue in a fresh project and share the repo.
Closing since no answer from the issue reporter.