Skip to content

Diagnostics

A graph assembled from real data is not always well formed. Rather than throw, the canvas reports each problem it finds through OnError - a BlowError with a stable code and a message naming the ids - and carries on drawing what it can. Each button breaks the graph in one of the six ways it reports.

A
B
OnError
Nothing reported.
bit Blow

Try it

  • Duplicate node id adds a second node called a: it is not drawn, and duplicate-node-id is reported. Press it again: another node with the same id is added, but it is the same problem, so nothing new is reported.
  • Duplicate edge id adds an edge from B back to A under the id a-b, which is taken: the new edge is not drawn (duplicate-edge-id).
  • Dangling edge adds an edge from A to a node that does not exist: it is not drawn (missing-edge-endpoint). Each press names a new missing node, so each is reported.
  • Orphan child adds a node whose parent does not exist: it is drawn as a root instead (missing-parent-node).
  • Parent cycle adds two nodes that name each other as parent: the loop is cut and they are drawn (parent-cycle).
  • Duplicate handles adds a node with two source handles and no ids: duplicate-handle-id is reported once the node has been measured. Drag from either handle and the new edge starts at the second.
  • Tick Hide B: the edge into B disappears with it, and nothing is reported - an edge to a hidden node is collapsed, not broken.
  • Reset puts back the two nodes and mounts a fresh canvas, so the same mistakes are reported again.

How it works

  • OnError receives a BlowError: a Code from BlowErrorCode and an English Message naming the elements. It is raised after the render that found the problem, never during it, and the canvas keeps working whether or not anyone listens.
  • The six codes and what the canvas does about each: DuplicateNodeId and DuplicateEdgeId - only the first element with the id is drawn and reachable; MissingEdgeEndpoint - the edge is not drawn; MissingParentNode - the node is laid out as a root; ParentCycle - the cycle is cut where it was found and that node is laid out as a root; DuplicateHandleId - the second handle takes the first one's edges.
  • Each distinct problem is reported once for the lifetime of the canvas, keyed by its code and the ids involved - otherwise a graph that stays broken would raise the same error on every frame of every drag. Giving the canvas a new @key, as Reset does, mounts a fresh one that reports everything again.
  • A hidden node is not an error: Hidden takes it out of the drawing, and its edges with it, because something has been collapsed rather than lost.
  • The duplicate handles are two BlowHandles of the same Type without an Id in a NodeTemplate; give each handle an Id and name it in the edge's SourceHandle or TargetHandle.
  • To find such problems before the graph reaches a canvas - on a server, or before saving - run BlowGraphValidator over it; /examples/graph-analysis does.
An unhandled error has occurred. Reload 🗙