Skip to content

Commit 9054e71

Browse files
authored
Typed Throws example fixes (#2278)
* Fixed `firstNameResultFromArray` example code in Proposal 0413: Typed Throws * Replace erroneous tabs with spaces in example code in Proposal 0413: Typed Throws
1 parent 796f409 commit 9054e71

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

proposals/0413-typed-throws.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,11 @@ func firstNameResultFromArray(_ array: [String]) throws(FirstNameError) -> Strin
311311

312312
func userResultFromStrings(strings: [String]) throws(SimpleError) -> User {
313313
do {
314-
let firstName = try stringFromArray(strings, at: 0, errorMessage: "Missing first name")
314+
let firstName = try firstNameResultFromArray(strings)
315315
return User(firstName: firstName, lastName: "")
316316
} catch {
317317
// error is a `FirstNameError`, map it to a `SimpleError`.
318-
throw SimpleError(message: "First name is missing")
318+
throw SimpleError(message: "Missing first name")
319319
}
320320
}
321321
```
@@ -365,7 +365,7 @@ func countNodes(in tree: Node, matching predicate: (Node) throws -> Bool) rethro
365365
}
366366

367367
override func visit(node: Node) {
368-
do {
368+
do {
369369
if try predicate(node) {
370370
count = count + 1
371371
}
@@ -420,7 +420,7 @@ func countNodes<E: Error>(in tree: Node, matching predicate: (Node) throws(E) ->
420420
}
421421

422422
override func visit(node: Node) {
423-
do {
423+
do {
424424
if try predicate(node) {
425425
count = count + 1
426426
}
@@ -1091,7 +1091,7 @@ func load(from dataLoader: dataLoader) {
10911091
do {
10921092
try dataLoader.load()
10931093
} catch {
1094-
processError(error)
1094+
processError(error)
10951095
}
10961096
}
10971097
```
@@ -1117,7 +1117,7 @@ func load(from dataLoader: dataLoader) {
11171117
do {
11181118
try dataLoader.load()
11191119
} catch {
1120-
processError(error)
1120+
processError(error)
11211121
}
11221122
}
11231123
```

0 commit comments

Comments
 (0)