diff --git a/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx b/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx
index 4846565bdd..a52b0d8f2c 100644
--- a/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx
+++ b/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.test.tsx
@@ -90,4 +90,17 @@ describe('', () => {
expect(getByText('No domains to display')).toBeInTheDocument(),
);
});
+
+ it('renders a friendly error if it cannot collect domains', async () => {
+ const catalogError = new Error('Network timeout');
+ catalogApi.getEntities.mockRejectedValueOnce(catalogError);
+
+ const { getByText } = render(, {
+ wrapper: Wrapper,
+ });
+
+ await waitFor(() =>
+ expect(getByText(/Could not load domains/)).toBeInTheDocument(),
+ );
+ });
});
diff --git a/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.tsx b/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.tsx
index ca00c525c9..182adf70ea 100644
--- a/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.tsx
+++ b/plugins/explore/src/components/DomainExplorerContent/DomainExplorerContent.tsx
@@ -21,6 +21,7 @@ import {
Progress,
SupportButton,
useApi,
+ WarningPanel,
} from '@backstage/core';
import { catalogApiRef } from '@backstage/plugin-catalog-react';
import { Button } from '@material-ui/core';
@@ -30,7 +31,7 @@ import { DomainCardGrid } from '../DomainCard';
export const DomainExplorerContent = () => {
const catalogApi = useApi(catalogApiRef);
- const { value: entities, loading } = useAsync(async () => {
+ const { value: entities, loading, error } = useAsync(async () => {
const response = await catalogApi.getEntities({
filter: { kind: 'domain' },
});
@@ -45,7 +46,12 @@ export const DomainExplorerContent = () => {
{loading && }
- {!loading && (!entities || entities.length === 0) && (
+ {error && (
+
+ {error.message}
+
+ )}
+ {!loading && !error && (!entities || entities.length === 0) && (