diff options
-rwxr-xr-x | doc/manual.txt | 17 | ||||
-rwxr-xr-x | doc/tut2.txt | 14 |
2 files changed, 31 insertions, 0 deletions
diff --git a/doc/manual.txt b/doc/manual.txt index 2a79c0f99..80a5642c5 100755 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -2843,6 +2843,23 @@ in an implicit try block: finally: close(f) ... +The ``except`` statement has a limitation in this form: you can't specify the +type of the exception, you have to catch everything. Also, if you want to use +both ``finally`` and ``except`` you need to reverse the usual sequence of the +statements. Example: + +.. code-block:: nimrod + proc test() = + raise newException(E_base, "Hey ho") + + proc tester() = + finally: echo "3. Finally block" + except: echo "2. Except block" + echo "1. Pre exception" + test() + echo "4. Post exception" + # --> 1, 2, 3 is printed, 4 is never reached + Raise statement --------------- diff --git a/doc/tut2.txt b/doc/tut2.txt index 9f9dbe2db..4a4ef1757 100755 --- a/doc/tut2.txt +++ b/doc/tut2.txt @@ -433,6 +433,20 @@ handled, it is propagated through the call stack. This means that often the rest of the procedure - that is not within a ``finally`` clause - is not executed (if an exception occurs). +If you need to *access* the actual exception object or message inside an +``except`` branch you can use the getCurrentException() and +getCurrentExceptionMsg() procs from the `system <system.html>`_ module. +Example: + +.. code-block:: nimrod + try: + doSomethingHere() + except: + let + e = getCurrentException() + msg = getCurrentExceptionMsg() + echo "Got exception ", repr(e), " with message ", msg + Exception hierarchy ------------------- |