mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Log error from App loading in console and faro (#79977)
* Chore: Log error from App loading in console and faro * Add error spy for console
This commit is contained in:
parent
c219a19f97
commit
5c67c4b082
@ -103,9 +103,12 @@ describe('AppRootPage', () => {
|
||||
});
|
||||
|
||||
it("should show a not found page if the plugin settings can't load", async () => {
|
||||
jest.spyOn(console, 'error').mockImplementation();
|
||||
getPluginSettingsMock.mockRejectedValue(new Error('Unknown Plugin'));
|
||||
// Renders once for the first time
|
||||
await renderUnderRouter();
|
||||
await act(async () => {
|
||||
await renderUnderRouter();
|
||||
});
|
||||
expect(await screen.findByText('App not found')).toBeVisible();
|
||||
});
|
||||
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
PluginType,
|
||||
PluginContextProvider,
|
||||
} from '@grafana/data';
|
||||
import { config, locationSearchToObject } from '@grafana/runtime';
|
||||
import { config, locationSearchToObject, logError } from '@grafana/runtime';
|
||||
import { Alert } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import PageLoader from 'app/core/components/PageLoader/PageLoader';
|
||||
@ -21,6 +21,7 @@ import { EntityNotFound } from 'app/core/components/PageNotFound/EntityNotFound'
|
||||
import { useGrafana } from 'app/core/context/GrafanaContext';
|
||||
import { appEvents, contextSrv } from 'app/core/core';
|
||||
import { getNotFoundNav, getWarningNav, getExceptionNav } from 'app/core/navigation/errorModels';
|
||||
import { getMessageFromError } from 'app/core/utils/errors';
|
||||
|
||||
import { getPluginSettings } from '../pluginSettings';
|
||||
import { importAppPlugin } from '../plugin_loader';
|
||||
@ -191,6 +192,9 @@ async function loadAppPlugin(pluginId: string, dispatch: React.Dispatch<AnyActio
|
||||
pluginNav: process.env.NODE_ENV === 'development' ? getExceptionNav(err) : getNotFoundNav(),
|
||||
})
|
||||
);
|
||||
const error = err instanceof Error ? err : new Error(getMessageFromError(err));
|
||||
logError(error);
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user