mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[KibanaErrorBoundary] Log the error that was caught (#189925)
Log the error that was caught to the console, so developers can interact with the stack trace messages. Addresses https://github.com/elastic/kibana/pull/168754#issuecomment-2268523404
This commit is contained in:
parent
83f6fa4872
commit
6b4f613ac2
4 changed files with 9 additions and 0 deletions
|
@ -17,6 +17,7 @@ import { BadComponent } from '../../mocks';
|
|||
describe('<KibanaErrorBoundaryProvider>', () => {
|
||||
let analytics: KibanaErrorBoundaryProviderDeps['analytics'];
|
||||
beforeEach(() => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
analytics = analyticsServiceMock.createAnalyticsServiceStart();
|
||||
});
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
import { KibanaErrorService } from './error_service';
|
||||
|
||||
describe('KibanaErrorBoundary Error Service', () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
const mockDeps = {
|
||||
analytics: { reportEvent: jest.fn() },
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@ import { errorMessageStrings as strings } from './message_strings';
|
|||
describe('<KibanaErrorBoundary>', () => {
|
||||
let services: KibanaErrorBoundaryServices;
|
||||
beforeEach(() => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
services = getServicesMock();
|
||||
});
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ class ErrorBoundaryInternal extends React.Component<
|
|||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
||||
console.error('Error caught by Kibana React Error Boundary'); // eslint-disable-line no-console
|
||||
console.error(error); // eslint-disable-line no-console
|
||||
|
||||
const { name, isFatal } = this.props.services.errorService.registerError(error, errorInfo);
|
||||
this.setState(() => {
|
||||
return { error, errorInfo, componentName: name, isFatal };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue