first commit
This commit is contained in:
commit
3c0479faf0
169 files changed
+27617
No files matched your search
@@ -0,0 +1,18 @@
|
||||
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 })
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user