summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/model/graph.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/model/graph.js b/scripts/model/graph.js
index e0881155..665b0a87 100644
--- a/scripts/model/graph.js
+++ b/scripts/model/graph.js
@@ -245,11 +245,14 @@ function Graph(el) {
}
this.addLinkByName = function(sourceName, targetName, name, state, drop_conjugator_links) {
- var sourceId = findNodeByName(sourceName, null).id;
- var targetId = findNodeByName(targetName, null).id;
+ var source = findNodeByName(sourceName, null),
+ target = findNodeByName(targetName, null),
+ sourceId = source ? source.id : null,
+ targetId = target ? target.id : null;
- if (sourceId === undefined || targetId === undefined) {
- console.log('error: cannot add link between names : ' + sourceName + ', ' + targetName);
+ if (sourceId === null || targetId === null) {
+ console.log('error: link of missing nodes: ' + sourceName + ' (' + sourceId + ') -> '
+ + targetName + ' (' + targetId + ')');
return;
}
this.addLink(sourceId, targetId, name, state, drop_conjugator_links);