From 41b74db2185f2f161f970319fed407ce98fca825 Mon Sep 17 00:00:00 2001 From: Ico Doornekamp Date: Sat, 1 Jun 2019 10:43:25 +0200 Subject: [PATCH] Added 'except X as Y' to section 'except clauses' of manual (#11371) --- doc/manual.rst | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/manual.rst b/doc/manual.rst index fafc1ea5b5..92d23f4566 100644 --- a/doc/manual.rst +++ b/doc/manual.rst @@ -3908,9 +3908,18 @@ follows a ``(`` it has to be written as a one liner: Except clauses -------------- -Within an ``except`` clause, it is possible to use -``getCurrentException`` to retrieve the exception that has been -raised: +Within an ``except`` clause it is possible to access the current exception +using the following syntax: + +.. code-block:: nim + try: + # ... + except IOError as e: + # Now use "e" + echo "I/O error: " & e.msg + +Alternatively, it is possible to use ``getCurrentException`` to retrieve the +exception that has been raised: .. code-block:: nim try: @@ -3937,8 +3946,8 @@ error message from ``e``, and for such situations it is enough to use .. code-block:: nim try: # ... - except IOError: - echo "I/O error: " & getCurrentExceptionMsg() + except: + echo getCurrentExceptionMsg() Defer statement