Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KibanaErrorBoundary] Log the error that was caught #189925

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { BadComponent } from '../../mocks';
describe('<KibanaErrorBoundaryProvider>', () => {
let analytics: KibanaErrorBoundaryProviderDeps['analytics'];
beforeEach(() => {
jest.spyOn(console, 'error').mockImplementation(() => {});
analytics = analyticsServiceMock.createAnalyticsServiceStart();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() },
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { errorMessageStrings as strings } from './message_strings';
describe('<KibanaErrorBoundary>', () => {
let services: KibanaErrorBoundaryServices;
beforeEach(() => {
jest.spyOn(console, 'error').mockImplementation(() => {});
services = getServicesMock();
});

Expand Down
3 changes: 3 additions & 0 deletions packages/shared-ux/error_boundary/src/ui/error_boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down