Error codes
Every code Wit 0.3 raises, the smallest source that triggers it, and the fix. Each trigger below was built and gives the code shown.
Unclosed and mismatched
| Code | Trigger | Fix |
|---|---|---|
E_UNCLOSED_NODE | @section on its own line, never closed | add section@ |
E_MISMATCHED_CLOSE | @section … aside@ | make the close name match the open |
E_UNCLOSED_PAREN | @img(src: a.png, then a blank line | close the params before the blank line |
E_UNCLOSED_STATEMENT | (if @x) with no (end) | add (end) |
E_UNCLOSED_COMMENT | Text ~~ never closed | add ~~/ |
E_UNCLOSED_COLLECTION | #x: [ [ a, b ] !! | balance the brackets |
E_UNTERMINATED_STRING | #x: { a: "open } !! | close the quote |
E_UNCLOSED_SCRIPT | <% a = 1 | add %> |
E_UNCLOSED_RAW_NODE | @@pre hi with no pre@@ | add the matching raw close |
Removed 0.2 syntax
Run wit migrate <file> -w to rewrite all of these; see Removed in 0.3.
| Code | Trigger | Fix |
|---|---|---|
E_PIPE_SYNTAX_REMOVED | @cite |author Weil|, #cite ||author|| | @cite(author: Weil), #cite(author) |
E_REMOVED_SYNTAX | @img { src: a.png }, @aside(class note) | @img(src: a.png), @aside(class: note) |
E_MALFORMED_RECORD | #x: { location - Bag End } !! | { location: Bag End } |
E_MALFORMED_STATEMENT | (if @p.s equals d) | (if @p.s is d); a statement is (if @path …) or (each @path as name) |
Definitions and parameters
Triggers below assume #cite(author, year): ::author:: (::year::) !!.
| Code | Trigger | Fix |
|---|---|---|
E_MISSING_PARAM | @cite(author: Weil) | pass every header parameter |
E_UNKNOWN_PARAM | @cite(Weil, 1952, place: Paris) | use a declared name, or add it to the header |
E_TOO_MANY_ARGUMENTS | @cite(Weil, S., 1952) | a value with a comma goes by name: @cite(author: Weil, S., year: 1952) |
E_POSITIONAL_WITHOUT_HEADER | @cite(Weil, 1952) when the definition is #cite: … !! | declare a header #cite(author, year), or pass by name |
E_BODY_WITHOUT_SLOT | @sig With thanks. sig@ when #sig has no ::body:: | drop the close and the body, or add ::body:: |
E_RESERVED_PARAM | #card(body) | rename it; ::body:: is the body slot |
E_MALFORMED_HEADER | #card(a b) | a header entry is name or literal name |
E_CONDITIONAL_DEFINITION | #s: DRAFT !! inside (if @p) … (end) | move the definition out; put the condition inside it |
E_DUPLICATE_DEFINITION | #x: 1 !! then #x: 2 !! | rename one, or make it an entry with +#x |
E_PARTIAL_SHAPE_MISMATCH | #b: one !! then +#b(who): ::who:: !! | give every entry the same shape and parameters |
E_MALFORMED_FORM_FIELD | a non-@key: value@ line in #w: … !! whose other lines are fields | make every line a field, or write a record { … } |
Data, references, runtime
| Code | Trigger | Fix |
|---|---|---|
E_UNRESOLVED_REFERENCE | See @nothing here. | define it, fix the spelling, or escape it: \@nothing |
E_RESERVED_FIELD | #a: [ { first: S, last: W } ] !! | rename the field; index, count and last are loop positions |
E_NOT_ITERABLE | (each @x as i) where @x is a record | loop over a collection |
E_AMBIGUOUS_RECORD_KEY | { first name: A, first_name: B }, then @r.firstName | keys match loosely — keep them distinct |
E_MISSING_REFERENCE_FILE | reference ./nope.wit | fix the path; it is relative to the referencing file |
E_CIRCULAR_REFERENCE | a.wit references b.wit, which references a.wit | move shared definitions into a third file |
E_EXPANSION_DEPTH_LIMIT | #a: @a !! then @a | remove the self-reference (limit 256) |
E_SCRIPT_ERROR | <% throw new Error("boom") %> | fix the script; the message is the JavaScript error |
E_LOAD_FAILED | @load nothing load@ with no source for nothing | add the alias to wit.sources.json and pass --allow-exec |
Declared, not raised
E_UNCLOSED_DEFINITION, E_MISSING_FIELD and E_TYPE_MISMATCH exist in the code tables but the current build
does not raise them. A missing field renders <span class="wit-unresolved">@x.field</span>; a definition missing
its name# ends at the next blank line (see limitations).
E_UNKNOWN_OUTPUT_FORMAT is a wit build message, not a
code: an -o extension it cannot map, with no --format. Exit 1.
Example
#cite(author, year) ::author:: (::year::) cite# @cite(Weil, S., 1952)
doc.wit:5:1: E_TOO_MANY_ARGUMENTS: @cite takes 2 positional values, got 3 — a value with a comma must be passed by namedoc.wit:5:1: E_TOO_MANY_ARGUMENTS: @cite takes 2 positional values, got 3 — a value with a comma must be passed by name
Warnings
wit check and wit build print warnings to stderr and still
succeed.
| Warning | Meaning |
|---|---|
W_UNRESOLVED_FIELD | @r.autor names no value; it renders as a marker |
W_UNUSED_DEFINITION | a definition in a file with content of its own that nothing uses |
W_SUSPECT_PARAM | a , key: the node doesn't declare, read into the value before it |
doc.wit:1:1: warning: W_UNUSED_DEFINITION: #note is defined but never used, so its text never appearsdoc.wit:1:1: warning: W_UNUSED_DEFINITION: #note is defined but never used, so its text never appears
See also
Syntax · Gotchas · CLI · Limitations.