mirror of
https://github.com/flarum/core.git
synced 2025-08-23 08:33:45 +02:00
Use resolver instead of catch-all route for errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import Page from '../../common/components/Page';
|
import Page from './Page';
|
||||||
|
|
||||||
export default class ErrorPage extends Page {
|
export default class ErrorPage extends Page {
|
||||||
view() {
|
view() {
|
@@ -1,4 +1,5 @@
|
|||||||
import Mithril from 'mithril';
|
import Mithril from 'mithril';
|
||||||
|
import ErrorPage from '../components/ErrorPage';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a route resolver for a given component.
|
* Generates a route resolver for a given component.
|
||||||
@@ -32,6 +33,13 @@ export default class DefaultResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onmatch(args, requestedPath, route) {
|
onmatch(args, requestedPath, route) {
|
||||||
|
const errorCode = app.data.errorCode;
|
||||||
|
const currRoute = m.route.get();
|
||||||
|
if (errorCode) {
|
||||||
|
delete app.data.errorCode;
|
||||||
|
return { view: () => ErrorPage.component({ errorCode, currRoute }) };
|
||||||
|
}
|
||||||
|
|
||||||
return this.component;
|
return this.component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@ import PostsUserPage from './components/PostsUserPage';
|
|||||||
import DiscussionsUserPage from './components/DiscussionsUserPage';
|
import DiscussionsUserPage from './components/DiscussionsUserPage';
|
||||||
import SettingsPage from './components/SettingsPage';
|
import SettingsPage from './components/SettingsPage';
|
||||||
import NotificationsPage from './components/NotificationsPage';
|
import NotificationsPage from './components/NotificationsPage';
|
||||||
import ErrorPage from './components/ErrorPage';
|
|
||||||
import DiscussionPageResolver from './resolvers/DiscussionPageResolver';
|
import DiscussionPageResolver from './resolvers/DiscussionPageResolver';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,8 +24,6 @@ export default function (app) {
|
|||||||
|
|
||||||
settings: { path: '/settings', component: SettingsPage },
|
settings: { path: '/settings', component: SettingsPage },
|
||||||
notifications: { path: '/notifications', component: NotificationsPage },
|
notifications: { path: '/notifications', component: NotificationsPage },
|
||||||
|
|
||||||
error: { path: '/:error', component: ErrorPage },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user