import { Exception } from '@adonisjs/core/exceptions' import type { HttpContext } from '@adonisjs/core/http' /** * An error whose message is meant for the user (shown as is in the * dashboard). Defaults to a 400 status. */ export default class UserError extends Exception { static status = 400 constructor(message: string, status?: number) { super(message, { status: status ?? UserError.status }) } async handle(error: this, ctx: HttpContext) { ctx.response.status(error.status).send({ message: error.message }) } }