parent
427490a845
commit
16c1a90857
12 changed files with 267 additions and 42 deletions
|
|
@ -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()
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue