Skip to content

Commit

Permalink
display operator placement loading error
Browse files Browse the repository at this point in the history
  • Loading branch information
imanjra committed Sep 17, 2024
1 parent 960cf9b commit 2173d35
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion app/packages/operators/src/OperatorPlacements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export function OperatorPlacementWithErrorBoundary(
props: OperatorPlacementProps
) {
return (
<ErrorBoundary Fallback={() => null}>
<ErrorBoundary
Fallback={(errorProps) => {
return <PlacementError {...props} {...errorProps} />;
}}
>
<OperatorPlacement {...props} />
</ErrorBoundary>
);
Expand All @@ -44,6 +48,28 @@ function OperatorPlacements(props: OperatorPlacementsProps) {
));
}

function PlacementError(props) {
const { adaptiveMenuItemProps, error, operator } = props;
console.error(error);
const operatorURI = operator?.uri;
const postfix = operatorURI ? ` for ${operatorURI}` : "";
return (
<PillButton
{...(getStringAndNumberProps(adaptiveMenuItemProps) || {})}
icon={
<OperatorIcon
icon="error"
iconProps={{ sx: { color: (theme) => theme.palette.error.main } }}
/>
}
title={error?.message || `Failed to load placement${postfix}`}
onClick={() => {
// do nothing
}}
/>
);
}

export default withSuspense(OperatorPlacements, () => null);

const componentByView = {
Expand Down

0 comments on commit 2173d35

Please sign in to comment.