summary refs log tree commit diff stats
path: root/doc
diff options
context:
space:
mode:
authorcooldome <cdome@bk.ru>2018-04-10 11:14:59 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-04-10 12:14:59 +0200
commit16c1a90857992df0960f53f5ffa578f14059cee4 (patch)
tree6c012aa972c6e2f8e048ef533f4c97d3b642ccf4 /doc
parent427490a845afa13c460d71c506994a24aae900c8 (diff)
downloadNim-16c1a90857992df0960f53f5ffa578f14059cee4.tar.gz
Cpp codegen: handling of imported exceptions. Fixes #3571 (#7360)
Diffstat (limited to 'doc')
-rw-r--r--doc/manual/exceptions.txt22
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