Skip to content

Commit

Permalink
Revert "remove error_boundary from core-application-browser-internal"
Browse files Browse the repository at this point in the history
This reverts commit bf11b802b2258482349deb65740f4d96ff1a81b5.
  • Loading branch information
tsullivan committed Oct 14, 2023
1 parent 642c396 commit 6371301
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import {
type AppUnmount,
type ScopedHistory,
} from '@kbn/core-application-browser';
import {
KibanaErrorBoundary,
KibanaErrorBoundaryKibanaProvider,
} from '@kbn/shared-ux-error-boundary';

import type { Mounter } from '../types';
import { AppNotFound } from './app_not_found_screen';

Expand Down Expand Up @@ -53,6 +58,7 @@ export const AppContainer: FC<Props> = ({
}: Props) => {
const [showSpinner, setShowSpinner] = useState(true);
const [appNotFound, setAppNotFound] = useState(false);
const [appError, setAppError] = useState<Error | null>(null);
const elementRef = useRef<HTMLDivElement>(null);
const unmountRef: MutableRefObject<AppUnmount | null> = useRef<AppUnmount>(null);

Expand Down Expand Up @@ -87,9 +93,9 @@ export const AppContainer: FC<Props> = ({
setHeaderActionMenu: (menuMount) => setAppActionMenu(appId, menuMount),
})) || null;
} catch (e) {
// TODO: add error UI
// eslint-disable-next-line no-console
console.error(e);
setAppError(e);
} finally {
if (elementRef.current) {
setShowSpinner(false);
Expand All @@ -113,7 +119,11 @@ export const AppContainer: FC<Props> = ({
theme$,
]);

return (
return appError ? (
<KibanaErrorBoundaryKibanaProvider toasts={null}>
<KibanaErrorBoundary as="callout" error={appError} />
</KibanaErrorBoundaryKibanaProvider>
) : (
<Fragment>
{appNotFound && <AppNotFound />}
{showSpinner && !appNotFound && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@kbn/core-analytics-browser-mocks",
"@kbn/core-analytics-browser",
"@kbn/shared-ux-router",
"@kbn/shared-ux-error-boundary",
],
"exclude": [
"target/**/*",
Expand Down

0 comments on commit 6371301

Please sign in to comment.