Skip to content

Commit 167365b

Browse files
committed
docs: Clarify that not all errors can be avoided
1 parent 6eca2a7 commit 167365b

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

docs/01_intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This library:
2323

2424
- Supports both YAML 1.1 and YAML 1.2 and all common data schemas,
2525
- Passes all of the [yaml-test-suite](https://github.com/yaml/yaml-test-suite) tests,
26-
- Can accept any string as input without throwing, parsing as much YAML out of it as it can, and
26+
- Can accept nearly any string as input without throwing, parsing as much YAML out of it as it can, and
2727
- Supports parsing, modifying, and writing YAML comments and blank lines.
2828

2929
The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/).

docs/02_parse_stringify.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ YAML.parse(file)
4040

4141
The returned value will match the type of the root value of the parsed YAML document, so Maps become objects, Sequences arrays, and scalars result in nulls, booleans, numbers and strings.
4242

43-
`YAML.parse` may throw on error, and it may log warnings using `console.warn`. It only supports input consisting of a single YAML document; for multi-document support you should use [`YAML.parseAllDocuments`](#parsing-documents).
43+
`YAML.parse` will throw on error, and it may log warnings using `console.warn`.
44+
It only supports input consisting of a single YAML document;
45+
for multi-document support you should use [`YAML.parseAllDocuments`](#parsing-documents).
4446

4547
## YAML.stringify
4648

docs/04_documents.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ doc.contents
4040
// range: [ 0, 180, 180 ] }
4141
```
4242

43-
These functions should never throw,
44-
provided that `str` is a string and the `options` are valid.
43+
These functions should not throw,
44+
provided that `str` is a reasonable string and the `options` are valid.
45+
Specially crafted inputs may still result in errors due to resource exhaustion,
46+
such as stack overflows.
4547
Errors and warnings are included in the documents' `errors` and `warnings` arrays.
4648
In particular, if `errors` is not empty
4749
it's likely that the document's parsed `contents` are not entirely correct.

docs/07_parsing_yaml.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ At the end of input, `lex()` should be called a final time with `incomplete: fal
4949

5050
Internally, the lexer operates a state machine that determines how it parses its input.
5151
Initially, the lexer is always in the `stream` state.
52-
The lexer constructor and its `lex()` method should never throw an error.
52+
The lexer constructor and its `lex()` method should never throw an error,
53+
except due to resource exhaustion.
5354

5455
All tokens are identifiable either by their exact value or their first character.
5556
In addition to slices of the input stream, a few control characters are additionally used within the output.

0 commit comments

Comments
 (0)