Initial commit

This commit is contained in:
Igor Martyniuk
2026-06-25 15:53:49 +03:00
commit 1bb0b7e68a
1517 changed files with 218469 additions and 0 deletions
@@ -0,0 +1,55 @@
import { Exception } from '@adonisjs/core/exceptions'
export class FilenameMissingExtensionException extends Exception {
static status = 400
static code = 'E_FILE_NAME_MISSING_EXTENSION'
constructor(message: string = 'File name missing extension') {
super(message)
}
}
export class EntryNameNotChangedException extends Exception {
static status = 400
static code = 'E_ENTRY_NAME_NOT_CHANGED'
constructor(message: string = 'Entry name was not changed') {
super(message)
}
}
export class EntryExistsException extends Exception {
static status = 400
static code = 'E_ENTRY_ALREADY_EXISTS'
constructor(message: string = 'Entry already exists') {
super(message)
}
}
export class DirExistsException extends Exception {
static status = 400
static code = 'E_DIRECTORY_ALREADY_EXISTS'
constructor(message: string = 'Directory already exists') {
super(message)
}
}
export class FileNotFoundException extends Exception {
static status = 404
static code = 'E_FILE_NOT_FOUND'
constructor(message: string = 'File not found') {
super(message)
}
}
export class DirNotFoundException extends Exception {
static status = 404
static code = 'E_DIR_NOT_FOUND'
constructor(message: string = 'Directory not found') {
super(message)
}
}
+66
View File
@@ -0,0 +1,66 @@
import app from '@adonisjs/core/services/app'
import { HttpContext, ExceptionHandler } from '@adonisjs/core/http'
import { Exception } from '@adonisjs/core/exceptions'
export default class HttpExceptionHandler extends ExceptionHandler {
/**
* In debug mode, the exception handler will display verbose errors
* with pretty printed stack traces.
*/
protected debug = !app.inProduction
/**
* The method is used for handling errors and returning
* response to the client
*/
async handle(error: unknown, ctx: HttpContext) {
if (error instanceof Exception && error.code === 'E_FILE_NAME_MISSING_EXTENSION') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_ENTRY_NAME_NOT_CHANGED') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_ENTRY_ALREADY_EXISTS') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_DIRECTORY_ALREADY_EXISTS') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_FILE_NOT_FOUND') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
if (error instanceof Exception && error.code === 'E_DIR_NOT_FOUND') {
return ctx.response.status(error.status).send({
message: error.message,
code: error.code,
})
}
return super.handle(error, ctx)
}
/**
* The method is used to report error to the logging service or
* the third party error monitoring service.
*
* @note You should not attempt to send a response from this method.
*/
async report(error: unknown, ctx: HttpContext) {
return super.report(error, ctx)
}
}