feat: create edit collection page

This commit is contained in:
Sonny
2024-05-14 23:57:54 +02:00
committed by Sonny
parent 6b327a5b1e
commit 6b4cfd9926
13 changed files with 180 additions and 38 deletions

View File

@@ -1,6 +1,11 @@
import PATHS from '#constants/paths';
import { ExceptionHandler, HttpContext } from '@adonisjs/core/http';
import app from '@adonisjs/core/services/app';
import { HttpContext, ExceptionHandler } from '@adonisjs/core/http';
import type { StatusPageRange, StatusPageRenderer } from '@adonisjs/core/types/http';
import type {
StatusPageRange,
StatusPageRenderer,
} from '@adonisjs/core/types/http';
import { errors } from '@adonisjs/lucid';
export default class HttpExceptionHandler extends ExceptionHandler {
/**
@@ -21,8 +26,10 @@ export default class HttpExceptionHandler extends ExceptionHandler {
* to return the HTML contents to send as a response.
*/
protected statusPages: Record<StatusPageRange, StatusPageRenderer> = {
'404': (error, { inertia }) => inertia.render('errors/not_found', { error }),
'500..599': (error, { inertia }) => inertia.render('errors/server_error', { error }),
'404': (error, { inertia }) =>
inertia.render('errors/not_found', { error }),
'500..599': (error, { inertia }) =>
inertia.render('errors/server_error', { error }),
};
/**
@@ -30,6 +37,9 @@ export default class HttpExceptionHandler extends ExceptionHandler {
* response to the client
*/
async handle(error: unknown, ctx: HttpContext) {
if (error instanceof errors.E_ROW_NOT_FOUND) {
return ctx.response.redirect(PATHS.DASHBOARD);
}
return super.handle(error, ctx);
}