| 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 |
|
| 19 | ## JSON
|
| 20 |
|
| 21 | ### json-encode-err
|
| 22 |
|
| 23 | JSON encoding has three possible errors:
|
| 24 |
|
| 25 | 1. Object of this type can't be serialized
|
| 26 | - For example, `Str List Dict` are YSH objects can be serialized.
|
| 27 | - But `Eggex Func Range` can't.
|
| 28 | 1. Circular reference
|
| 29 | - e.g. a Dict that points to itself, a List that points to itself, and other
|
| 30 | permutations
|
| 31 | 1. Float values of NaN, Inf, and -Inf can't be encoded.
|
| 32 | - TODO: option to use `null` like JavaScript.
|
| 33 | 1. Invalid UTF-8 in string, e.g. binary data like `\xfe\xff`
|
| 34 | - TODO: option to use the Unicode replacement char to avoid an error.
|
| 35 |
|
| 36 | ### json-decode-err
|
| 37 |
|
| 38 | 1. The encoded message itself is not valid UTF-8.
|
| 39 | - (Typically, you need to check the unescaped bytes in string literals
|
| 40 | `"abc\n"`).
|
| 41 | 1. Lexical error, like
|
| 42 | - the message `+`
|
| 43 | - an invalid escape `"\z"` or a truncated escape `"\u1"`
|
| 44 | - A single quoted string like `u''`
|
| 45 | 1. Grammatical error
|
| 46 | - like the message `}{`
|
| 47 | 1. Unexpected trailing input
|
| 48 | - like the message `42]` or `{}]`
|
| 49 |
|
| 50 | ## JSON8
|
| 51 |
|
| 52 | ### json8-encode-err
|
| 53 |
|
| 54 | Compared to JSON, JSON8 removes an encoding error:
|
| 55 |
|
| 56 | 5. Invalid UTF-8 is OK, because it gets turned into a binary string like
|
| 57 | `b"byte \yfe\yff"`.
|
| 58 |
|
| 59 | ### json8-decode-err
|
| 60 |
|
| 61 | JSON8 has the same decoding errors as JSON, plus:
|
| 62 |
|
| 63 | 4. `\u{dc00}` should not be in the surrogate range. This means it doesn't
|
| 64 | represent a real character, and `\yff` escapes should be used instead.
|
| 65 | 4. `\yff` should not be in `u''` string. (It's only valid in `b''` strings.)
|
| 66 |
|
| 67 | ## Packle
|
| 68 |
|
| 69 | ### packle-encode-err
|
| 70 |
|
| 71 | Packle has no encoding errors!
|
| 72 |
|
| 73 | 1. TODO: Unserializable `Eggex Func Range` can be turned into "wire Tuple"
|
| 74 | `(type_name: Str, heap_id: Int)`.
|
| 75 | - When you read a packle into Python, you'll get a tuple.
|
| 76 | - When you read a packle back into YSH, you'll get a `value.Tombstone`?
|
| 77 | 1. Circular references are allowed. Packle data expresses a **graph**, not a
|
| 78 | tree.
|
| 79 | 1. Float values NaN, Inf, and -Inf use their binary representations.
|
| 80 | 1. Both Unicode and binary data are allowed.
|
| 81 |
|
| 82 | ### packle-decode-err
|
| 83 |
|
| 84 | TODO
|
| 85 |
|
| 86 | ## UTF8
|
| 87 |
|
| 88 | This is for reference.
|
| 89 |
|
| 90 | ### utf8-encode-err
|
| 91 |
|
| 92 | Oils stores strings as UTF-8 in memory, so it doesn't often do encoding.
|
| 93 |
|
| 94 | - Surrogate range?
|
| 95 |
|
| 96 | ### utf8-decode-err
|
| 97 |
|
| 98 | #### bad-byte
|
| 99 |
|
| 100 | #### expected-start
|
| 101 |
|
| 102 | #### expected-cont
|
| 103 |
|
| 104 | #### incomplete-seq
|
| 105 |
|
| 106 | #### overlong
|
| 107 |
|
| 108 | I think this is only leading zeros?
|
| 109 |
|
| 110 | Like the difference between `123` and `0123`.
|
| 111 |
|
| 112 | #### bad-code-point
|
| 113 |
|
| 114 | e.g. decoded to something in the surrogate range
|
| 115 |
|
| 116 | Note: I think this is relaxed for WTF-8, and our JSON decoder probably needs to
|
| 117 | use it.
|
| 118 |
|
| 119 |
|