Remove invalid statements about try in async docs. (#19108)

This commit is contained in:
Dominik Picheta 2021-11-08 07:21:15 +00:00 • committed by GitHub
commit b423ab138f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,16 +101,9 @@
## Handling Exceptions ## Handling Exceptions
## ------------------- ## -------------------
## ##
## The most reliable way to handle exceptions is to use `yield` on a future ## You can handle exceptions in the same way as in ordinary Nim code;
## then check the future's `failed` property. For example: ## by using the try statement:
## ##
## .. code-block:: Nim
## var future = sock.recv(100)
## yield future
## if future.failed:
## # Handle exception
##
## The `async` procedures also offer limited support for the try statement.
## ##
## .. code-block:: Nim ## .. code-block:: Nim
## try: ## try:
@ -119,9 +112,16 @@
## except: ## except:
## # Handle exception ## # Handle exception
## ##
## Unfortunately the semantics of the try statement may not always be correct, ##
## and occasionally the compilation may fail altogether. ##
## As such it is better to use the former style when possible. ## An alternative approach to handling exceptions is to use `yield` on a future
## then check the future's `failed` property. For example:
##
## .. code-block:: Nim
## var future = sock.recv(100)
## yield future
## if future.failed:
## # Handle exception
## ##
## ##
## Discarding futures ## Discarding futures
@ -1987,4 +1987,4 @@ when defined(linux) or defined(windows) or defined(macosx) or defined(bsd) or
var fdLim: RLimit var fdLim: RLimit
if getrlimit(RLIMIT_NOFILE, fdLim) < 0: if getrlimit(RLIMIT_NOFILE, fdLim) < 0:
raiseOSError(osLastError()) raiseOSError(osLastError())
result = int(fdLim.rlim_cur) - 1 result = int(fdLim.rlim_cur) - 1