Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Diagnostics

A diagnostic is a problem with the user’s design or input, explained in the user’s terms, with a stable code. Diagnostics are values: the engine collects them and keeps planning whatever it can. Errors in the Rust sense (Result) are reserved for failures to do the work at all (architecture).

pub struct Diagnostic {
    pub code: Code,                  // SC-W0702
    pub severity: Severity,          // Error | Warning | Info
    pub element: Option<ElementId>,  // which object
    pub at: Option<Point>,           // where on the canvas (mm)
    pub message: String,             // one sentence, specific: "Design is 162 × 148 mm; …"
    pub fix: Option<Fix>,            // a hint, or a machine-applicable fix
}

Codes

SC- + E (error: this element, or the design, cannot be stitched), W (warning: stitched, but probably not what you want) or I (info) + four digits grouped by area:

RangeArea
0000–0099Input and budgets
0100–0199Parameters
0200–0299Satin
0300–0399Fills
0400–0499Strokes (running, bean, manual, zigzag, ripple)
0500–0599Plan assembly (ties, travel, trims, colours)
0600–0699Formats and threads
0700–0799Machine profile (hoop, limits)
0800–0899Hosts (SVG, VectorCraft)
0900 to 0999Automatic digitizing (image to embroidery)

Codes are never reused. A retired code keeps its page with “retired in vX”.

The registry

All codes live in one table in stitchcraft-core: the registry! block in src/diag.rs, which defines the Code enum. Each entry is one line — variant, id, severity, title — and its doc comment is the long explanation (Markdown: what it means, why it matters for the sew-out, how to fix it), so the text users read is also the code’s rustdoc. Tests reject an entry whose id is malformed or duplicated, whose letter disagrees with its severity, or whose explanation is missing. From that table:

  • cargo xtask docs generates the diagnostics index (one page per code, like rustc’s error index);
  • stitch explain SC-W0702 prints the explanation in the terminal;
  • in VectorCraft, the plug-in shows each message after its code, for the user to look up in the index or with stitch explain;
  • cargo xtask conformance fails when a code has no diag_sc_<code>_<what> test that produces it from real input and checks the text a user reads, or when such a test names a code that is not registered (conformance); the registry’s own tests fail when a code has no explanation.

That last rule is what keeps error paths alive: a message that no test ever renders can ship with a typo in its formatting and nobody sees it until a user does.

Writing good messages

  • Say what is wrong and by how much: “Rows are 0.25 mm apart but the region is only 0.18 mm tall.”
  • Name the object and point at the place.
  • Offer the fix in embroidery terms: “Use a running stitch for parts this thin, or widen the shape.”
  • No blame, no internal names (LineString, GEOS), no stack traces.

As text

A diagnostic reads the same wherever StitchCraft prints it. Its Display is the severity, the code and the message: warning SC-W0702: Design is 190.0 × 150.0 mm; …. Diagnostic::headline adds the object it is about, as in warning SC-W0307 (svg:patch:fill): The area falls into 2 parts., and the command line prints that, with the fix on the line below. Diagnostic::one_line puts the fix after the headline, for a host that shows each diagnostic as one line of text, as VectorCraft shows an export’s warnings.

Fixes

Fix::Hint(String) is advice. Fix::Apply(Edit) is a change the host can apply with one click and undo (for example “rotate the design 90°” for SC-W0702 when the rotated bounds fit, or “drop the dangling rung” for SC-W0203). Applied fixes go through the host’s command system so they are undoable.

Initial codes

Codes referenced by the design docs; each is registered in the milestone that implements it. A registered code must keep its row here, with the same severity and a title that starts with the registry’s (cargo xtask docs --check), so a code allocated for one thing cannot be registered for another.

CodeSeverityTitleMilestone
SC-E0004ErrorBudget exhausted (work for one element, work joining the elements, or stitches for the design)M1
SC-E0005ErrorPreview too large (over 4,096 pixels on a side at the requested scale)M2
SC-E0009ErrorInternal check failed (a StitchCraft bug; a bug-report bundle is written)M1
SC-E0010ErrorNothing to stitch (no embroiderable elements)M1
SC-W0011WarningStitch type not sewn yet; element skippedM3
SC-E0012ErrorBug-report bundle could not be replayedM3
SC-E0101ErrorParameter has the wrong type or an unknown choiceM3
SC-W0102WarningParameter clamped to its allowed rangeM3
SC-W0105WarningUnknown parameter preserved but ignoredM3
SC-E0201ErrorSatin column has no rails (no subpath longer than a point)M4
SC-W0202WarningSatin rails taken as the two longest subpaths (where the subpaths meet does not say)M4
SC-W0203WarningSatin rung does not cross both rails (dangling rung); the rail’s nearest point is usedM4
SC-W0205WarningSatin subpath is one point; left outM4
SC-W0206WarningSatin contour underlay too short for its insets; it keeps its lengthM4
SC-W0207WarningSatin rung crosses a rail more than once; left outM4
SC-W0208WarningSatin stitches lean more than 45° from square to the column; add a rung hereM7
SC-W0209WarningSatin stitch longer than 12 mm; it may snagM7
SC-W0210WarningSatin rails without rungs have different numbers of nodes (some pair with none)M4
SC-W0211WarningSatin push compensation too long for a rail; that rail keeps its lengthM4
SC-W0212WarningSatin column drawn as one path too narrow; sewn as a strokeM4
SC-W0213WarningParts of a satin column drawn as one path left out (still crossing after 20 cuts in half, or turning too tightly for its width)M4
SC-E0214ErrorSatin column drawn as one path could not be made into rails (too short, or too tight for its width)M4
SC-W0215WarningSatin column too small for the shortest stitch; left out (all within it of its first needle point, or a zigzag satin with no stitch across, underlays and all; Ink/Stitch sews a speck)M4
SC-E0216ErrorSatin column has no section to sew (its rungs or push compensation take each section’s length off a rail)M4
SC-W0303WarningParts of a fill too small to sew left out (3 square CSS pixels or less, as in Ink/Stitch); a fill of no area sews nothingM5
SC-W0304WarningFill smaller than 1.4 mm² (20 square CSS pixels); a running stitch or a satin column may sew it betterM5
SC-W0305WarningFill part too thin for rows; sewn round its outline (as in Ink/Stitch)M5
SC-I0306InfoNonzero fill rule fills a part inside that the even-odd rule leaves empty (Ink/Stitch leaves it empty)M5
SC-W0307WarningFill in parts that are apart; each sewn on its own, joined by jumpsM5
SC-I0308InfoFill underlay too thin for rows; sewn round the outline (as in Ink/Stitch)M5
SC-W0309WarningFill’s expand shrinks a part away; sewn at its own size (as in Ink/Stitch)M5
SC-W0310WarningFill’s underlay inset shrinks a part away; underlay over all of it (as in Ink/Stitch)M5
SC-W0311WarningContour fill leaves out rings it does not reach, where its rings part or lie too far apartM7
SC-W0312WarningFill’s pull compensation below 0; read as 0 (as in Ink/Stitch)M5
SC-I0313InfoFill drawn twice along its edge; Ink/Stitch fills the part left empty (its repair merges the stretch)M5
SC-W0314WarningLegacy fill sewn as a tatami fill without underlay (Ink/Stitch’s legacy fill is not built)M7
SC-W0401WarningPath too small for the shortest stitch; skippedM3
SC-W0402WarningStitch length below twice the shortest stitch; raised to it, so even spacing never sews a stitch shorter than the shortestM3
SC-W0403WarningHand-placed stitch shorter than the shortest stitch; point left outM3
SC-W0404WarningHand-placed stitch longer than max_stitch_length_mm; kept for the shortest stitchM3
SC-W0405WarningZigzag stitch shorter than the shortest stitch; the zigzag sews narrowerM7
SC-W0502WarningLock stitch shorter than 0.2 mm; lengthenedM3
SC-W0503WarningCustom lock cannot be sewn as writtenM3
SC-I0504InfoStitches shorter than the shortest stitch mergedM3
SC-W0505WarningTrim or stop after an element that sews nothing; left outM3
SC-E0601ErrorToo many colour changes for the file formatM1
SC-E0602ErrorDesign too large for the file format (coordinates or data exceed its fields)M1
SC-E0603ErrorMachine file could not be read (wrong format, truncated, or a record that makes no sense)M2
SC-W0604WarningThread colours unknown (the file stores none, as DST never does; threads are placeholders)M2
SC-I0605InfoLong jumps cut in DST (machines cut the thread before three or more jump records in a row)M3
SC-W0606WarningThreads share a Brother colour (more different threads than a PES file’s 61 thread colours)M3
SC-E0701ErrorDesign does not fit the hoopM1
SC-W0702WarningDesign is larger than the comfort zone (the profile’s most accurate area)M1
SC-I0703InfoStitches longer than the machine’s longest stitch; splitM3
SC-E0801ErrorSVG could not be read (with the parser’s position)M3
SC-W0802WarningSVG feature ignored (e.g. raster image, text not converted to paths)M3
SC-W0803WarningVectorCraft file from a newer format version; read best-effort (a version newer than the newest the adapter reads)M6
SC-W0804WarningElement geometry invalid or out of range (path data error, invalid transform, draws nothing, beyond 10 m, a stroke’s width, join or miter limit that does not read); the usable part is stitchedM3
SC-I0805InfoObject left out, as the file asks (Ink/Stitch’s ignore commands and ignore_object setting)M3
SC-E0806ErrorVectorCraft file could not be read (not a VectorCraft document, or larger than the adapter reads)M6
SC-W0807WarningVectorCraft object or feature not stitched (text, images, symbols, live objects, clipping, VectorCraft’s own effects, brushes, gradients, patterns, a group’s own paints), StitchCraft effects from more than one level, a start or end marker, or a stitch: name StitchCraft doesn’t readM6
SC-W0808WarningVectorCraft geometry unusable (a number that does not read or a point beyond 10 m; a shape that draws nothing)M6
SC-I0809InfoVectorCraft layer or guide left out, as it does not print (template layers, layers whose printing is off, guides)M6
SC-I0810InfoVectorCraft live effect leaves the object as it is (it sews no stitch, its preview level needs more work than VectorCraft lets a live effect do, it is a satin column drawn as one path or a zigzag stroke and VectorCraft gives the effect no stroke, or the effect is on one of the object’s fills or strokes)M6
SC-I0811InfoVectorCraft object left out, as its name asks (an object or a layer named stitch:ignore)M6
SC-W0812WarningVectorCraft design setting ignored (a length that isn’t a number of 0 or more, or a machine StitchCraft doesn’t have, which the Design Settings filter keeps with the document)M6
SC-E0813ErrorVectorCraft too old for the filter (the Design Settings filter run by a VectorCraft before 0.16, which doesn’t keep a filter’s data, Stroke to Satin by one before 0.15, which doesn’t keep a filter’s effect records, and Test Sheet by one before 0.16, which doesn’t say it keeps them)M6
SC-E0814ErrorVectorCraft line not made into a satin column (Stroke to Satin refused a selection because it is empty or a path has no stroke, or because a line drawn with its rails and rungs would sew otherwise)M6
SC-I0901InfoShapes digitized automatically (--auto), counted by their stitches (running stitches, satin columns or tatami fills)M13
SC-I0902InfoLine a satin column cannot follow; filled (a part of an automatic line that turns more tightly than it is wide or is shorter than a CSS pixel, or a dot its cap draws)M13
SC-W0903WarningLine too wide to fill; left out (an automatic line whose filled area would reach more than 10 m from the origin)M13
SC-I0904InfoAreas reach under the shapes sewn after them (automatic areas grown 0.4 mm under the shapes sewn after them that they touch, or cut away under areas sewn after them)M13
SC-I0905InfoSpeck merged into a neighbour (an automatic area or a part of one smaller than 1 mm², merged into the area it shares the longest edge with, or left out)M13
SC-W0906WarningBackground left out (the lowest shape, an automatic area that covers the whole design under the other shapes)M13
SC-I0907InfoElements sewn in an order of their own (automatic elements, and with --sort-colours every element, sewn in the order StitchCraft chooses, with the thread changes of each order; an element or an order that needs more work than the budget allows keeps paint order)M13