Skip to content

Commit

Permalink
Try to parse DOT and don't attempt to render if parsing fails
Browse files Browse the repository at this point in the history
This speeds up feedback for erroneus DOT and reduces the risk of
triggering #22
  • Loading branch information
magjac committed Aug 29, 2018
1 parent b3bbc31 commit 28b4f2b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class Graph extends React.Component {
this.prevFit = this.props.fit;
}
this.prevDotSrc = this.props.dotSrc;
try {
this.prelDotGraph = new DotGraph(this.props.dotSrc);
}
catch(error) {
let {location: {start: {line}}, message} = error;
this.props.onError({message: message, line: line});
return;
}
this.rendering = true;
this.graphviz
.width(width)
Expand All @@ -129,13 +137,7 @@ class Graph extends React.Component {
handleRenderGraphReady() {
this.svg = this.div.selectWithoutDataPropagation("svg");
this.graph0 = this.svg.selectWithoutDataPropagation("g");
try {
this.dotGraph = new DotGraph(this.props.dotSrc);
}
catch(error) {
let {location: {start: {line}}, message} = error;
this.props.onError({message: message, line: line});
}
this.dotGraph = this.prelDotGraph;
this.addEventHandlers();
this.rendering = false;
if (!this.renderGraphReady) {
Expand Down

0 comments on commit 28b4f2b

Please sign in to comment.