OILS / doc / ref / chap-errors.md View on Github | oilshell.org

129 lines, 84 significant
1---
2in_progress: yes
3body_css_class: width40 help-body
4default_highlighter: oils-sh
5preserve_anchor_case: yes
6---
7
8Errors
9======
10
11This chapter in the [Oils Reference](index.html) describes **errors**.
12
13Related: [Oils Error Catalog, With Hints](../error-catalog.html).
14
15<div id="toc">
16</div>
17
18## J8 Lines
19
20### j8-lines-decode-err
21
22J8 Lines is used by `@(split command sub)`, and has these errors:
23
241. An unquoted line is not valid UTF-8.
251. A J8 quoted string has a syntax error (e.g. no closing quote, invalid
26 backslash escape)
271. A line has extra text after a quoted string, e.g. `"mystr" extra`.
28
29## JSON
30
31### json-encode-err
32
33JSON encoding has three possible errors:
34
351. Object of this type can't be serialized
36 - For example, `Str List Dict` are YSH objects can be serialized.
37 - But `Eggex Func Range` can't.
381. Circular reference
39 - e.g. a Dict that points to itself, a List that points to itself, and other
40 permutations
411. Float values of NaN, Inf, and -Inf can't be encoded.
42 - TODO: option to use `null` like JavaScript.
431. Invalid UTF-8 in string, e.g. binary data like `\xfe\xff`
44 - TODO: option to use the Unicode replacement char to avoid an error.
45
46### json-decode-err
47
481. The encoded message itself is not valid UTF-8.
49 - (Typically, you need to check the unescaped bytes in string literals
50 `"abc\n"`).
511. Lexical error, like
52 - the message `+`
53 - an invalid escape `"\z"` or a truncated escape `"\u1"`
54 - A single quoted string like `u''`
551. Grammatical error
56 - like the message `}{`
571. Unexpected trailing input
58 - like the message `42]` or `{}]`
59
60## JSON8
61
62### json8-encode-err
63
64Compared to JSON, JSON8 removes an encoding error:
65
665. Invalid UTF-8 is OK, because it gets turned into a binary string like
67 `b"byte \yfe\yff"`.
68
69### json8-decode-err
70
71JSON8 has the same decoding errors as JSON, plus:
72
734. `\u{dc00}` should not be in the surrogate range. This means it doesn't
74 represent a real character, and `\yff` escapes should be used instead.
754. `\yff` should not be in `u''` string. (It's only valid in `b''` strings.)
76
77## Packle
78
79### packle-encode-err
80
81Packle has no encoding errors!
82
831. TODO: Unserializable `Eggex Func Range` can be turned into "wire Tuple"
84 `(type_name: Str, heap_id: Int)`.
85 - When you read a packle into Python, you'll get a tuple.
86 - When you read a packle back into YSH, you'll get a `value.Tombstone`?
871. Circular references are allowed. Packle data expresses a **graph**, not a
88 tree.
891. Float values NaN, Inf, and -Inf use their binary representations.
901. Both Unicode and binary data are allowed.
91
92### packle-decode-err
93
94TODO
95
96## UTF8
97
98This is for reference.
99
100### utf8-encode-err
101
102Oils stores strings as UTF-8 in memory, so it doesn't often do encoding.
103
104- Surrogate range?
105
106### utf8-decode-err
107
108#### bad-byte
109
110#### expected-start
111
112#### expected-cont
113
114#### incomplete-seq
115
116#### overlong
117
118I think this is only leading zeros?
119
120Like the difference between `123` and `0123`.
121
122#### bad-code-point
123
124e.g. decoded to something in the surrogate range
125
126Note: I think this is relaxed for WTF-8, and our JSON decoder probably needs to
127use it.
128
129