Skip to content
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 @@ -87,6 +87,7 @@ describe('AppLayout error boundaries: errors in different areas does not crash t
(wrappedWithErrorBoundary: boolean) => {
const onError = jest.fn();
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
const AppLayoutWrapper = wrappedWithErrorBoundary ? ErrorBoundary : 'div';
const appLayoutWrapperProps = wrappedWithErrorBoundary ? { onError } : {};
const content = <div>content</div>;
Expand All @@ -104,6 +105,10 @@ describe('AppLayout error boundaries: errors in different areas does not crash t
appLayoutPart,
errorMessage: expect.any(String),
});
expect(consoleLogSpy).toHaveBeenCalledWith(
`[AwsUiAppLayoutError] appLayoutPart=${appLayoutPart}`,
expect.anything()
);
}
const reportedParts = sendPanoramaMetricSpy.mock.calls
.filter(call => call[0] === 'awsui-app-layout-error-boundary-fired')
Expand Down
1 change: 1 addition & 0 deletions src/error-boundary/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function AppLayoutBuiltInErrorBoundary({
errorMessage: error?.error?.message ?? '',
appLayoutPart: appLayoutPart ?? '',
});
console.log(`[AwsUiAppLayoutError] appLayoutPart=${appLayoutPart ?? ''}`, error?.error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not console.error?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the purpose of error boundaries is, at least in part, to allow errors to be caught and handled gracefully. At this point, we don't know whether this error will be caught by a higher-level and handled in some way there or not, so IMO it's better to be rather cautious and use log instead of error here to prevent creating error messages when the error is actually caught and handled gracefully.

}}
>
<ErrorBoundariesContext.Provider value={{ ...context, suppressed: nextSuppressed, renderFallback }}>
Expand Down
Loading