diff options
Diffstat (limited to 'doc/manual/exceptions.txt')
-rw-r--r-- | doc/manual/exceptions.txt | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/doc/manual/exceptions.txt b/doc/manual/exceptions.txt index 0f1240a4a..63adff776 100644 --- a/doc/manual/exceptions.txt +++ b/doc/manual/exceptions.txt @@ -156,3 +156,25 @@ Exception hierarchy The exception tree is defined in the `system <system.html>`_ module: .. include:: ../exception_hierarchy_fragment.txt + + +Imported exceptions +------------------- + +It is possible to raise/catch imported C++ exceptions. Types imported using +`importcpp` can be raised or caught. Exceptions are raised by value and +caught by reference. Example: + +.. code-block:: nim + + type + std_exception {.importcpp: "std::exception", header: "<exception>".} = object + + proc what(s: std_exception): cstring {.importcpp: "((char *)#.what())".} + + try: + raise std_exception() + except std_exception as ex: + echo ex.what() + + \ No newline at end of file |