diff --git a/x-pack/plugins/profiling/public/app.tsx b/x-pack/plugins/profiling/public/app.tsx
index bf3a35d060f0..bf2f53aed0b0 100644
--- a/x-pack/plugins/profiling/public/app.tsx
+++ b/x-pack/plugins/profiling/public/app.tsx
@@ -22,6 +22,7 @@ import { profilingRouter } from './routing';
import { Services } from './services';
import { ProfilingPluginPublicSetupDeps, ProfilingPluginPublicStartDeps } from './types';
import { ProfilingHeaderActionMenu } from './components/profiling_header_action_menu';
+import { RouterErrorBoundary } from './routing/router_error_boundary';
interface Props {
profilingFetchServices: Services;
@@ -82,21 +83,23 @@ function App({
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/x-pack/plugins/profiling/public/routing/router_error_boundary.tsx b/x-pack/plugins/profiling/public/routing/router_error_boundary.tsx
new file mode 100644
index 000000000000..355ee1bd42f7
--- /dev/null
+++ b/x-pack/plugins/profiling/public/routing/router_error_boundary.tsx
@@ -0,0 +1,71 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+import { NotFoundRouteException } from '@kbn/typed-react-router-config';
+import { EuiErrorBoundary } from '@elastic/eui';
+import { useKibana } from '@kbn/kibana-react-plugin/public';
+import React from 'react';
+import { NotFoundPrompt } from '@kbn/shared-ux-prompt-not-found';
+import { useLocation } from 'react-router-dom';
+import { i18n } from '@kbn/i18n';
+import { ProfilingPluginPublicStartDeps } from '../types';
+
+export function RouterErrorBoundary({ children }: { children?: React.ReactNode }) {
+ const location = useLocation();
+ return {children};
+}
+
+class ErrorBoundary extends React.Component<{ children?: React.ReactNode }, { error?: Error }, {}> {
+ public state: { error?: Error } = {
+ error: undefined,
+ };
+
+ static getDerivedStateFromError(error: Error) {
+ return { error };
+ }
+
+ render() {
+ if (this.state.error) {
+ return ;
+ }
+
+ return this.props.children;
+ }
+}
+
+const pageHeader = {
+ pageTitle: i18n.translate('xpack.profiling.universalProfiling', {
+ defaultMessage: 'Universal Profiling',
+ }),
+};
+
+function ErrorWithTemplate({ error }: { error: Error }) {
+ const { services } = useKibana();
+ const { observability } = services;
+
+ const ObservabilityPageTemplate = observability.navigation.PageTemplate;
+
+ if (error instanceof NotFoundRouteException) {
+ return (
+
+
+
+ );
+ }
+
+ return (
+
+
+
+
+
+ );
+}
+
+function DummyComponent({ error }: { error: Error }) {
+ throw error;
+ return ;
+}
diff --git a/x-pack/plugins/profiling/tsconfig.json b/x-pack/plugins/profiling/tsconfig.json
index b1044792b320..636413998241 100644
--- a/x-pack/plugins/profiling/tsconfig.json
+++ b/x-pack/plugins/profiling/tsconfig.json
@@ -40,6 +40,7 @@
"@kbn/core-http-request-handler-context-server",
"@kbn/spaces-plugin",
"@kbn/cloud-plugin",
+ "@kbn/shared-ux-prompt-not-found",
// add references to other TypeScript projects the plugin depends on
// requiredPlugins from ./kibana.json