Skip to content

Broken Nodes

Edges built from real data can point at things that are not there. Rather than throw, the canvas skips an edge whose node is missing, draws an edge to a missing handle at the middle of the node's side, and draws only the first of two edges sharing an id. What counts as a mistake is reported once through OnError.

Node 1
Node 2
Node 4
bit Blow

Try it

  • At the start node 3 is missing: edge e3-2 names a node that is not in the list, so it is not drawn, nothing breaks, and the footer shows missing-edge-endpoint.
  • Set node 3 to present: the node joins the list and its edge to node 2's right-hand handle appears.
  • Set node 3 to hidden: it stays in the list but is not drawn, and neither is its edge - and nothing is reported, since hiding a node is not a mistake.
  • Tick e1-2 names a missing handle: the edge leaves node 2's left-hand handle and ends at the middle of its top side, between the two real handles. Nothing is reported for this one.
  • Tick add a second edge with the id e2-4: the new edge, from node 1 to node 4, never appears - only the first edge with an id is drawn - and duplicate-edge-id is reported.
  • Go back to a broken state you have seen: the footer does not repeat it, because each problem is reported once for the lifetime of the canvas.

How it works

  • OnError receives a BlowError: a stable Code (the BlowErrorCode constants) and a Message naming the ids. It is raised after the render that found the problem, never during it.
  • An edge whose Source or Target names no node is not drawn and is reported as missing-edge-endpoint. An edge to a node with Hidden = true is not drawn either, and is not an error.
  • An edge's TargetHandle and SourceHandle are matched against the ids of the node's handles. With no match, the end is anchored at the middle of the node's TargetPosition or SourcePosition side - where it is also drawn before the node's first measurement - and no error is raised.
  • Node 2 declares its handles through Ports: the built-in node draws one handle per port, and the two target ports sharing the top side are spread a third and two thirds along it, which leaves the fallback anchor visible between them.
  • Of two edges with the same Id, only the first in the list is drawn (duplicate-edge-id); nodes behave the same way (duplicate-node-id). The Diagnostics example breaks a graph in the other ways OnError reports.
An unhandled error has occurred. Reload 🗙