Skip to content

Commit

Permalink
fix: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Sep 25, 2024
1 parent 0e4ba1a commit 596b87a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/library-authoring/component-info/ComponentDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useIntl } from '@edx/frontend-platform/i18n';
import { Stack } from '@openedx/paragon';

import AlertError from '../../generic/alert-error';
import Loading from '../../generic/loading';

Check failure on line 5 in src/library-authoring/component-info/ComponentDetails.tsx

View workflow job for this annotation

GitHub Actions / tests (18)

Unable to resolve path to module '../../generic/loading'

Check failure on line 5 in src/library-authoring/component-info/ComponentDetails.tsx

View workflow job for this annotation

GitHub Actions / tests (18)

Missing file extension for "../../generic/loading"

Check failure on line 5 in src/library-authoring/component-info/ComponentDetails.tsx

View workflow job for this annotation

GitHub Actions / tests (20)

Unable to resolve path to module '../../generic/loading'

Check failure on line 5 in src/library-authoring/component-info/ComponentDetails.tsx

View workflow job for this annotation

GitHub Actions / tests (20)

Missing file extension for "../../generic/loading"
import { useLibraryBlockMetadata } from '../data/apiHooks';
import HistoryWidget from '../generic/history-widget';
import { ComponentDeveloperInfo } from './ComponentDeveloperInfo';
Expand All @@ -12,11 +14,19 @@ interface ComponentDetailsProps {

const ComponentDetails = ({ usageKey }: ComponentDetailsProps) => {
const intl = useIntl();
const { data: componentMetadata } = useLibraryBlockMetadata(usageKey);
const {
data: componentMetadata,
isError,
error,
isLoading,
} = useLibraryBlockMetadata(usageKey);

// istanbul ignore if: this should never happen
if (!componentMetadata) {
return null;
if (isError) {
return <AlertError error={error} />;
}

if (isLoading) {
return <Loading />;
}

return (
Expand Down

0 comments on commit 596b87a

Please sign in to comment.