File tree Expand file tree Collapse file tree 2 files changed +5
-6
lines changed
TSPL.docc/ReferenceManual Expand file tree Collapse file tree 2 files changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -1476,16 +1476,14 @@ func <#function name#>(<#parameters#>) throws(<#error type#>) -> <#return type#>
14761476Calls to a throwing function or method must be wrapped in a ` try ` or ` try! ` expression
14771477(that is, in the scope of a ` try ` or ` try! ` operator).
14781478
1479- <!-- XXX
1480- Rule for inferring the thrown error type
1481- Xref to the guide <doc:ErrorHandling#Specifying-a-Concrete-Error-Type>
1482- -->
1483-
14841479A function's type includes whether it can throw an error,
14851480and what type of error it throws.
14861481This means, for example, you can use a nonthrowing function
14871482in a context where a throwing one is expected.
1488- For more information, see < doc:Types#Function-Type > .
1483+ For more information about the type of a throwing function,
1484+ see < doc:Types#Function-Type > .
1485+ For examples of working with errors that have explicit types,
1486+ see < doc:ErrorHandling#Specifying-a-Concrete-Error-Type > .
14891487
14901488You can't overload a function based only on whether the function can throw an error.
14911489That said,
Original file line number Diff line number Diff line change @@ -351,6 +351,7 @@ that can throw or rethrow an error must include the `throws` keyword.
351351<!-- XXX TR: Confirm rethrowing functions use 'throws' -->
352352You can include a type after ` throws ` in parentheses
353353to specify the type of error that the function throws.
354+ The throw error type must conform to the ` Error ` protocol.
354355Writing ` throws ` without specifying an type
355356is the same as writing ` throws(any Error) ` .
356357Omitting ` throws ` is the same as writing ` throws(Never) ` .
You can’t perform that action at this time.
0 commit comments