| 1 | ---
|
| 2 | in_progress: yes
|
| 3 | body_css_class: width40 help-body
|
| 4 | default_highlighter: oils-sh
|
| 5 | preserve_anchor_case: yes
|
| 6 | ---
|
| 7 |
|
| 8 | Errors
|
| 9 | ======
|
| 10 |
|
| 11 | This chapter in the [Oils Reference](index.html) describes **errors**.
|
| 12 |
|
| 13 | Related: [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 |
|
| 22 | J8 Lines is used by `@(split command sub)`, and has these errors:
|
| 23 |
|
| 24 | 1. An unquoted line is not valid UTF-8.
|
| 25 | 1. A J8 quoted string has a syntax error (e.g. no closing quote, invalid
|
| 26 | backslash escape)
|
| 27 | 1. A line has extra text after a quoted string, e.g. `"mystr" extra`.
|
| 28 |
|
| 29 | ## JSON
|
| 30 |
|
| 31 | ### json-encode-err
|
| 32 |
|
| 33 | JSON encoding has three possible errors:
|
| 34 |
|
| 35 | 1. 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.
|
| 38 | 1. Circular reference
|
| 39 | - e.g. a Dict that points to itself, a List that points to itself, and other
|
| 40 | permutations
|
| 41 | 1. Float values of NaN, Inf, and -Inf can't be encoded.
|
| 42 | - TODO: option to use `null` like JavaScript.
|
| 43 | 1. 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 |
|
| 48 | 1. The encoded message itself is not valid UTF-8.
|
| 49 | - (Typically, you need to check the unescaped bytes in string literals
|
| 50 | `"abc\n"`).
|
| 51 | 1. Lexical error, like
|
| 52 | - the message `+`
|
| 53 | - an invalid escape `"\z"` or a truncated escape `"\u1"`
|
| 54 | - A single quoted string like `u''`
|
| 55 | 1. Grammatical error
|
| 56 | - like the message `}{`
|
| 57 | 1. Unexpected trailing input
|
| 58 | - like the message `42]` or `{}]`
|
| 59 |
|
| 60 | ## JSON8
|
| 61 |
|
| 62 | ### json8-encode-err
|
| 63 |
|
| 64 | Compared to JSON, JSON8 removes an encoding error:
|
| 65 |
|
| 66 | 5. 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 |
|
| 71 | JSON8 has the same decoding errors as JSON, plus:
|
| 72 |
|
| 73 | 4. `\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.
|
| 75 | 4. `\yff` should not be in `u''` string. (It's only valid in `b''` strings.)
|
| 76 |
|
| 77 | ## Packle
|
| 78 |
|
| 79 | ### packle-encode-err
|
| 80 |
|
| 81 | Packle has no encoding errors!
|
| 82 |
|
| 83 | 1. 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`?
|
| 87 | 1. Circular references are allowed. Packle data expresses a **graph**, not a
|
| 88 | tree.
|
| 89 | 1. Float values NaN, Inf, and -Inf use their binary representations.
|
| 90 | 1. Both Unicode and binary data are allowed.
|
| 91 |
|
| 92 | ### packle-decode-err
|
| 93 |
|
| 94 | TODO
|
| 95 |
|
| 96 | ## UTF8
|
| 97 |
|
| 98 | This is for reference.
|
| 99 |
|
| 100 | ### utf8-encode-err
|
| 101 |
|
| 102 | Oils 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 |
|
| 118 | I think this is only leading zeros?
|
| 119 |
|
| 120 | Like the difference between `123` and `0123`.
|
| 121 |
|
| 122 | #### bad-code-point
|
| 123 |
|
| 124 | e.g. decoded to something in the surrogate range
|
| 125 |
|
| 126 | Note: I think this is relaxed for WTF-8, and our JSON decoder probably needs to
|
| 127 | use it.
|
| 128 |
|
| 129 |
|