Remove invalid statements about try in async docs. (#19108)
This commit is contained in:
parent
fce89cb60a
commit
b423ab138f
1 changed files with 13 additions and 13 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue