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:
| Range | Area |
|---|---|
| 0000–0099 | Input and budgets |
| 0100–0199 | Parameters |
| 0200–0299 | Satin |
| 0300–0399 | Fills |
| 0400–0499 | Strokes (running, bean, manual, zigzag, ripple) |
| 0500–0599 | Plan assembly (ties, travel, trims, colours) |
| 0600–0699 | Formats and threads |
| 0700–0799 | Machine profile (hoop, limits) |
| 0800–0899 | Hosts (SVG, VectorCraft) |
| 0900 to 0999 | Automatic 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 docsgenerates the diagnostics index (one page per code, likerustc’s error index);stitch explain SC-W0702prints 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 conformancefails when a code has nodiag_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.
| Code | Severity | Title | Milestone |
|---|---|---|---|
SC-E0004 | Error | Budget exhausted (work for one element, work joining the elements, or stitches for the design) | M1 |
SC-E0005 | Error | Preview too large (over 4,096 pixels on a side at the requested scale) | M2 |
SC-E0009 | Error | Internal check failed (a StitchCraft bug; a bug-report bundle is written) | M1 |
SC-E0010 | Error | Nothing to stitch (no embroiderable elements) | M1 |
SC-W0011 | Warning | Stitch type not sewn yet; element skipped | M3 |
SC-E0012 | Error | Bug-report bundle could not be replayed | M3 |
SC-E0101 | Error | Parameter has the wrong type or an unknown choice | M3 |
SC-W0102 | Warning | Parameter clamped to its allowed range | M3 |
SC-W0105 | Warning | Unknown parameter preserved but ignored | M3 |
SC-E0201 | Error | Satin column has no rails (no subpath longer than a point) | M4 |
SC-W0202 | Warning | Satin rails taken as the two longest subpaths (where the subpaths meet does not say) | M4 |
SC-W0203 | Warning | Satin rung does not cross both rails (dangling rung); the rail’s nearest point is used | M4 |
SC-W0205 | Warning | Satin subpath is one point; left out | M4 |
SC-W0206 | Warning | Satin contour underlay too short for its insets; it keeps its length | M4 |
SC-W0207 | Warning | Satin rung crosses a rail more than once; left out | M4 |
SC-W0208 | Warning | Satin stitches lean more than 45° from square to the column; add a rung here | M7 |
SC-W0209 | Warning | Satin stitch longer than 12 mm; it may snag | M7 |
SC-W0210 | Warning | Satin rails without rungs have different numbers of nodes (some pair with none) | M4 |
SC-W0211 | Warning | Satin push compensation too long for a rail; that rail keeps its length | M4 |
SC-W0212 | Warning | Satin column drawn as one path too narrow; sewn as a stroke | M4 |
SC-W0213 | Warning | Parts 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-E0214 | Error | Satin column drawn as one path could not be made into rails (too short, or too tight for its width) | M4 |
SC-W0215 | Warning | Satin 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-E0216 | Error | Satin column has no section to sew (its rungs or push compensation take each section’s length off a rail) | M4 |
SC-W0303 | Warning | Parts 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 nothing | M5 |
SC-W0304 | Warning | Fill smaller than 1.4 mm² (20 square CSS pixels); a running stitch or a satin column may sew it better | M5 |
SC-W0305 | Warning | Fill part too thin for rows; sewn round its outline (as in Ink/Stitch) | M5 |
SC-I0306 | Info | Nonzero fill rule fills a part inside that the even-odd rule leaves empty (Ink/Stitch leaves it empty) | M5 |
SC-W0307 | Warning | Fill in parts that are apart; each sewn on its own, joined by jumps | M5 |
SC-I0308 | Info | Fill underlay too thin for rows; sewn round the outline (as in Ink/Stitch) | M5 |
SC-W0309 | Warning | Fill’s expand shrinks a part away; sewn at its own size (as in Ink/Stitch) | M5 |
SC-W0310 | Warning | Fill’s underlay inset shrinks a part away; underlay over all of it (as in Ink/Stitch) | M5 |
SC-W0311 | Warning | Contour fill leaves out rings it does not reach, where its rings part or lie too far apart | M7 |
SC-W0312 | Warning | Fill’s pull compensation below 0; read as 0 (as in Ink/Stitch) | M5 |
SC-I0313 | Info | Fill drawn twice along its edge; Ink/Stitch fills the part left empty (its repair merges the stretch) | M5 |
SC-W0314 | Warning | Legacy fill sewn as a tatami fill without underlay (Ink/Stitch’s legacy fill is not built) | M7 |
SC-W0401 | Warning | Path too small for the shortest stitch; skipped | M3 |
SC-W0402 | Warning | Stitch length below twice the shortest stitch; raised to it, so even spacing never sews a stitch shorter than the shortest | M3 |
SC-W0403 | Warning | Hand-placed stitch shorter than the shortest stitch; point left out | M3 |
SC-W0404 | Warning | Hand-placed stitch longer than max_stitch_length_mm; kept for the shortest stitch | M3 |
SC-W0405 | Warning | Zigzag stitch shorter than the shortest stitch; the zigzag sews narrower | M7 |
SC-W0502 | Warning | Lock stitch shorter than 0.2 mm; lengthened | M3 |
SC-W0503 | Warning | Custom lock cannot be sewn as written | M3 |
SC-I0504 | Info | Stitches shorter than the shortest stitch merged | M3 |
SC-W0505 | Warning | Trim or stop after an element that sews nothing; left out | M3 |
SC-E0601 | Error | Too many colour changes for the file format | M1 |
SC-E0602 | Error | Design too large for the file format (coordinates or data exceed its fields) | M1 |
SC-E0603 | Error | Machine file could not be read (wrong format, truncated, or a record that makes no sense) | M2 |
SC-W0604 | Warning | Thread colours unknown (the file stores none, as DST never does; threads are placeholders) | M2 |
SC-I0605 | Info | Long jumps cut in DST (machines cut the thread before three or more jump records in a row) | M3 |
SC-W0606 | Warning | Threads share a Brother colour (more different threads than a PES file’s 61 thread colours) | M3 |
SC-E0701 | Error | Design does not fit the hoop | M1 |
SC-W0702 | Warning | Design is larger than the comfort zone (the profile’s most accurate area) | M1 |
SC-I0703 | Info | Stitches longer than the machine’s longest stitch; split | M3 |
SC-E0801 | Error | SVG could not be read (with the parser’s position) | M3 |
SC-W0802 | Warning | SVG feature ignored (e.g. raster image, text not converted to paths) | M3 |
SC-W0803 | Warning | VectorCraft file from a newer format version; read best-effort (a version newer than the newest the adapter reads) | M6 |
SC-W0804 | Warning | Element 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 stitched | M3 |
SC-I0805 | Info | Object left out, as the file asks (Ink/Stitch’s ignore commands and ignore_object setting) | M3 |
SC-E0806 | Error | VectorCraft file could not be read (not a VectorCraft document, or larger than the adapter reads) | M6 |
SC-W0807 | Warning | VectorCraft 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 read | M6 |
SC-W0808 | Warning | VectorCraft geometry unusable (a number that does not read or a point beyond 10 m; a shape that draws nothing) | M6 |
SC-I0809 | Info | VectorCraft layer or guide left out, as it does not print (template layers, layers whose printing is off, guides) | M6 |
SC-I0810 | Info | VectorCraft 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-I0811 | Info | VectorCraft object left out, as its name asks (an object or a layer named stitch:ignore) | M6 |
SC-W0812 | Warning | VectorCraft 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-E0813 | Error | VectorCraft 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-E0814 | Error | VectorCraft 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-I0901 | Info | Shapes digitized automatically (--auto), counted by their stitches (running stitches, satin columns or tatami fills) | M13 |
SC-I0902 | Info | Line 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-W0903 | Warning | Line too wide to fill; left out (an automatic line whose filled area would reach more than 10 m from the origin) | M13 |
SC-I0904 | Info | Areas 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-I0905 | Info | Speck 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-W0906 | Warning | Background left out (the lowest shape, an automatic area that covers the whole design under the other shapes) | M13 |
SC-I0907 | Info | Elements 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 |