mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: create edit collection page
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user