Skip to content

Commit a0ee3a9

Browse files
committed
Iterate on editorial feedback
1 parent 4baad40 commit a0ee3a9

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

TSPL.docc/LanguageGuide/ErrorHandling.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,9 @@ To specify that a function throws only `StatisticsError` values as its errors,
762762
you write `throws(StatisticsError)` instead of only `throws`
763763
when declaring the function.
764764
This syntax is also called *typed throws*
765-
because you write the error type after `throws` --- for example:
765+
because you write the error type after `throws` in the declaration.
766+
For example,
767+
the function below throws `StatisticsError` values as its errors.
766768

767769
```swift
768770
func summarize(_ ratings: [Int]) throws(StatisticsError) {
@@ -808,7 +810,7 @@ func someThrowingFunction() -> throws {
808810

809811
The code above doesn't specify an error type for `someThrowingFunction()`,
810812
so it throws `any Error`.
811-
You could also write the error type explicitly as `throws(any Error)` ---
813+
You could also write the error type explicitly as `throws(any Error)`;
812814
the code below is equivalent to the code above:
813815

814816
```swift

TSPL.docc/ReferenceManual/Declarations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ Calls to a throwing function or method must be wrapped in a `try` or `try!` expr
14781478

14791479
A function's type includes whether it can throw an error
14801480
and what type of error it throws.
1481-
This means, for example, you can use a nonthrowing function
1481+
This subtype relationship means, for example, you can use a nonthrowing function
14821482
in a context where a throwing one is expected.
14831483
For more information about the type of a throwing function,
14841484
see <doc:Types#Function-Type>.

TSPL.docc/ReferenceManual/Statements.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,21 +898,21 @@ a concrete type that conforms to the `Error` protocol,
898898
an opaque type that conforms to the `Error` protocol,
899899
or the boxed protocol type `any Error`.
900900
If the `do` statement doesn't specify the type of error it throws,
901-
the error type is inferred as follows:
901+
Swift infers the error type as follows:
902902

903903
- If every `throws` statement and `try` expression in the `do` code block
904904
is nested inside of an exhaustive error-handling mechanism,
905-
then the `do` statement is inferred as nonthrowing.
905+
then Swift infers that the `do` statement is nonthrowing.
906906

907907
- If the `do` code block contains code that throws
908908
errors of only a single type
909909
outside of exhaustive error handling,
910-
then the `do` statement is inferred as throwing that concrete error type.
910+
then Swift infers that the `do` statement throws that concrete error type.
911911

912912
- If the `do` code block contains code that throws
913913
errors of more than a single type
914914
outside of exhaustive error handling,
915-
then the `do` statement is inferred as throwing `any Error`.
915+
then Swift infers that the `do` statement throws `any Error`.
916916

917917
For more information about working with errors that have explicit types,
918918
see <doc:ErrorHandling#Specifying-a-Concrete-Error-Type>.

0 commit comments

Comments
 (0)