Skip to content

Commit

Permalink
handle error in promise
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbranham committed Feb 20, 2021
1 parent 389bd8f commit 10f3d0f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/DiagramController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export class DiagramPanelController extends React.Component<DiagramPanelControll
mermaidAPI.initialize(options);
// parseError = this.handleParseError.bind(this);
if (this.diagramRef) {
try {
this.loadDiagramDefinition().then(diagramDefinition => {
this.loadDiagramDefinition().then(diagramDefinition => {
try {
const diagramId = `diagram-${this.props.id}`;
const interpolated = this.props.replaceVariables(this.contentProcessor(diagramDefinition));
// if parsing the graph definition fails, the error handler will be called but the renderCallback() may also still be called.
Expand All @@ -154,10 +154,10 @@ export class DiagramPanelController extends React.Component<DiagramPanelControll
if (this.bindFunctions) {
this.bindFunctions(this.diagramRef);
}
});
} catch (err) {
this.diagramRef.innerHTML = `<div><p>Error rendering diagram. Check the diagram definition</p><p>${err}</p></div>`;
}
} catch (err) {
this.diagramRef.innerHTML = `<div><p>Error rendering diagram. Check the diagram definition</p><p>${err}</p></div>`;
}
});
}
}

Expand Down

0 comments on commit 10f3d0f

Please sign in to comment.