diff options
| author | Alon Levy <alon@pobox.com> | 2014-11-11 11:21:07 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-11-11 11:21:07 +0200 |
| commit | 1cd350f16c2a686e96a6a87113ac026fd4440bd8 (patch) | |
| tree | 2cc604eaa61cdfcf2a36a7c96ee3e55d64f7b7c7 /scripts/model/graph.js | |
| parent | 7b4fb125b77d4b8671ea2908e98fd3d844944c9b (diff) | |
graph: addLinkByName: end fix of unchought exception on missing id
Diffstat (limited to 'scripts/model/graph.js')
| -rw-r--r-- | scripts/model/graph.js | 11 |
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); |
