@@ -11,6 +11,8 @@ import {
11
11
VisualizationSurface ,
12
12
getSpacerNodes ,
13
13
} from '@patternfly/react-topology' ;
14
+ import { EmptyState , EmptyStateBody , EmptyStateIcon , Title } from '@patternfly/react-core' ;
15
+ import { ExclamationCircleIcon } from '@patternfly/react-icons' ;
14
16
15
17
type PipelineVisualizationSurfaceProps = {
16
18
nodes : PipelineNodeModel [ ] ;
@@ -22,23 +24,42 @@ const PipelineVisualizationSurface: React.FC<PipelineVisualizationSurfaceProps>
22
24
selectedIds,
23
25
} ) => {
24
26
const controller = useVisualizationController ( ) ;
25
-
27
+ const [ error , setError ] = React . useState < Error | null > ( ) ;
26
28
React . useEffect ( ( ) => {
27
29
// PF Bug
28
30
// TODO: Pipeline Topology weirdly doesn't set a width and height on spacer nodes -- but they do when using finally spacer nodes
29
31
const spacerNodes = getSpacerNodes ( nodes ) . map ( ( s ) => ( { ...s , width : 1 , height : 1 } ) ) ;
30
32
const renderNodes = [ ...spacerNodes , ...nodes ] ;
31
33
// TODO: We can have a weird edge issue if the node is off by a few pixels vertically from the center
32
34
const edges = getEdgesFromNodes ( renderNodes ) ;
33
-
34
- controller . fromModel (
35
- {
36
- nodes : renderNodes ,
37
- edges,
38
- } ,
39
- true ,
40
- ) ;
35
+ try {
36
+ controller . fromModel (
37
+ {
38
+ nodes : renderNodes ,
39
+ edges,
40
+ } ,
41
+ true ,
42
+ ) ;
43
+ } catch ( error ) {
44
+ if ( error instanceof Error ) {
45
+ setError ( error ) ;
46
+ } else {
47
+ // eslint-disable-next-line no-console
48
+ console . error ( 'Unknown error occurred rendering Pipeline Graph' , error ) ;
49
+ }
50
+ }
41
51
} , [ controller , nodes ] ) ;
52
+ if ( error ) {
53
+ return (
54
+ < EmptyState data-id = "error-empty-state" >
55
+ < EmptyStateIcon icon = { ExclamationCircleIcon } />
56
+ < Title headingLevel = "h4" size = "lg" >
57
+ Incorrect pipeline definition
58
+ </ Title >
59
+ < EmptyStateBody > { error . message } </ EmptyStateBody >
60
+ </ EmptyState >
61
+ ) ;
62
+ }
42
63
43
64
return (
44
65
< TopologyView
0 commit comments