Commit d4af3735 by Andreas Opferkuch Committed by GitHub

AppPlugin: Show exceptions in dev (#26795)

When NODE_ENV is dev, print exceptions that
bubble up from an app plugin to the console and
make developer aware of this instead of only
"404 Error".
parent 325240fc
......@@ -53,6 +53,11 @@ export class NavModelSrv {
}
}
export function getExceptionNav(error: any): NavModel {
console.error(error);
return getWarningNav('Exception thrown', 'See console for details');
}
export function getNotFoundNav(): NavModel {
return getWarningNav('Page not found', '404 Error');
}
......
......@@ -9,7 +9,7 @@ import { AppEvents, AppPlugin, AppPluginMeta, NavModel, PluginType, UrlQueryMap
import Page from 'app/core/components/Page/Page';
import { getPluginSettings } from './PluginSettingsCache';
import { importAppPlugin } from './plugin_loader';
import { getNotFoundNav, getWarningNav } from 'app/core/nav_model_srv';
import { getNotFoundNav, getWarningNav, getExceptionNav } from 'app/core/nav_model_srv';
import { appEvents } from 'app/core/core';
import PageLoader from 'app/core/components/PageLoader/PageLoader';
......@@ -62,7 +62,11 @@ class AppRootPage extends Component<Props, State> {
});
this.setState({ plugin: app, loading: false });
} catch (err) {
this.setState({ plugin: null, loading: false, nav: getNotFoundNav() });
this.setState({
plugin: null,
loading: false,
nav: process.env.NODE_ENV === 'development' ? getExceptionNav(err) : getNotFoundNav(),
});
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment